Skip to content

Can't connect to Redis through a unix socket #1507

@diogotcorreia

Description

@diogotcorreia

Hey,
I'm packaging Dawarich for Nixpkgs, and we usually use Unix sockets for connecting to Redis and Postgres.
It appears that the way Dawarich constructs only works for host/port URLs and not for unix:// URIs.

OS & Hardware
NixOS 25.11 (unstable, master branch)
Hardware is irrelevant for this issue

Version
0.29.1

Describe the bug

Code in Dawarich adds /<number> to the value of REDIS_URL.
This works fine for redis:// URIs, but breaks unix:// URIs, since it is just treated a path separator.
The correct syntax for unix:// URIs would be ?db=<number>.

See https://github.com/redis-rb/redis-client/blob/98a51a42c9952f76238da7f6390315e7d1edb6b3/lib/redis_client/url_config.rb#L30-L42

To Reproduce

  1. Setup Redis with unix sockets
  2. Set REDIS_URL to unix:///run/redis-dawarich/redis.sock
  3. Try to run the migrations

Expected behavior
Dawarich should support both unix:// and redis:// URIs.

Logs

machine # [   54.538659] dawarich-init-db-start[1001]: Tasks: TOP => data:migrate
machine # [   54.539811] dawarich-init-db-start[1001]: (See full trace by running task with --trace)
machine # [   54.541120] dawarich-init-db-start[1001]: Migrating to BindExistingPointsToFirstUser (20240525110530)
machine # [   54.542560] dawarich-init-db-start[1001]: == 20240525110530 BindExistingPointsToFirstUser: migrating ====================
machine # [   54.544216] dawarich-init-db-start[1001]: == 20240525110530 BindExistingPointsToFirstUser: migrated (0.0510s) ===========
machine # [   54.545935] dawarich-init-db-start[1001]: Migrating to RemovePointsWithoutCoordinates (20240610170930)
machine # [   54.547383] dawarich-init-db-start[1001]: == 20240610170930 RemovePointsWithoutCoordinates: migrating ===================
machine # [   54.549008] dawarich-init-db-start[1001]: Found 0 points without coordinates...
machine # [   54.550278] dawarich-init-db-start[1001]: Points without coordinates removed.
machine # [   54.551477] dawarich-init-db-start[1001]: INFO  2025-07-09T17:31:48.798Z pid=1001 tid=221: Sidekiq 8.0.4 connecting to Redis with options {size: 10, pool_name: "internal", url: "unix:///run/redis-dawarich/redis.sock/1"}
machine # [   54.554235] dawarich-init-db-start[1001]: Failed enqueuing BulkStatsCalculatingJob to Sidekiq(stats): RedisClient::CannotConnectError (Not a directory - connect(2) for /run/redis-dawarich/redis.sock/1 (unix:///run/redis-dawarich/redis.sock/1))
machine # [   54.559829] systemd[1]: dawarich-init-db.service: Main process exited, code=exited, status=1/FAILURE
machine # [   54.561625] systemd[1]: dawarich-init-db.service: Failed with result 'exit-code'.
machine # [   54.564899] systemd[1]: Failed to start dawarich-init-db.service.

Solution

A possible solution would be to use the built-in db argument instead, since it works with any type of URI.

See https://github.com/redis-rb/redis-client/blob/98a51a42c9952f76238da7f6390315e7d1edb6b3/lib/redis_client/config.rb#L198-L201

Additional context
Bug introduced with #1420

I have a working fix and will be making a PR shortly.

Relates to NixOS/nixpkgs#345622

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions