Support Redis Unix sockets #9588

Closed
opened 2025-12-29 21:19:19 +01:00 by adam · 6 comments
Owner

Originally created by @tacerus on GitHub (May 6, 2024).

Originally assigned to: @minijackson on GitHub.

NetBox version

3.7.5

Feature type

Change to existing functionality

Proposed functionality

Support Redis connectivity through Unix sockets

Use case

Binding to Redis servers on localhost or sidecars without exposing a TCP listener.

Database changes

No response

External dependencies

No response

Originally created by @tacerus on GitHub (May 6, 2024). Originally assigned to: @minijackson on GitHub. ### NetBox version 3.7.5 ### Feature type Change to existing functionality ### Proposed functionality Support Redis connectivity through Unix sockets ### Use case Binding to Redis servers on localhost or sidecars without exposing a TCP listener. ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: featurecomplexity: medium labels 2025-12-29 21:19:19 +01:00
adam closed this issue 2025-12-29 21:19:20 +01:00
Author
Owner
@tacerus commented on GitHub (May 6, 2024): https://github.com/netbox-community/netbox/issues/15955 https://github.com/netbox-community/netbox/issues/4377 https://github.com/netbox-community/netbox/pull/15590
Author
Owner

@arthanson commented on GitHub (May 6, 2024):

From previous tickets:

Proposed Functionality

Implement unix-socket support for Redis cache and webhook

Use Case

When Redis is installed on the same Server as netbox, then the possible usage of unix sockets for redis would be nice. When using unix sockets, there is no need for localhost loopback with the whole IP-Stack. The usage with unix sockets can improve the performance too (even if it doesn't matter).

Database Changes

No DB-Changes needed. Just some small changes in settings.py and configuration.py

@arthanson commented on GitHub (May 6, 2024): From previous tickets: ### Proposed Functionality Implement unix-socket support for Redis cache and webhook ### Use Case When Redis is installed on the same Server as netbox, then the possible usage of unix sockets for redis would be nice. When using unix sockets, there is no need for localhost loopback with the whole IP-Stack. The usage with unix sockets can improve the performance too (even if it doesn't matter). ### Database Changes No DB-Changes needed. Just some small changes in settings.py and configuration.py
Author
Owner

@minijackson commented on GitHub (May 7, 2024):

Hello, I have a patch that I'm willing to upstream that was made to support Redis Unix sockets.

(Note: the linked patch also modifies STATIC_ROOT, but this modification is not part of the proposed changes)

This patch defines new REDIS['tasks']['URL'] and REDIS['caching']['URL'] settings, which take priority if defined by the user. The user can then set this config if they want to use Unix sockets:

REDIS = {
    "tasks": {"URL": "unix:///run/redis-netbox/redis.sock?db=0", "SSL": False},
    "caching": {"URL": "unix:///run/redis-netbox/redis.sock?db=1", "SSL": False},
}

In the case of the tasks Redis database, if and only if URL is defined, NetBox would use it.

In the case of the caching Redis database, URL is always used, but defaults to the value that was used before the patch.

This should be backwards compatible.

@minijackson commented on GitHub (May 7, 2024): Hello, I have [a patch](https://github.com/NixOS/nixpkgs/blob/dd1290b0f857782a60b251f89651c831cd3eef9d/pkgs/servers/web-apps/netbox/config.patch) that I'm willing to upstream that was made to support Redis Unix sockets. (Note: the linked patch also modifies `STATIC_ROOT`, but this modification is not part of the proposed changes) This patch defines new `REDIS['tasks']['URL']` and `REDIS['caching']['URL']` settings, which take priority if defined by the user. The user can then set this config if they want to use Unix sockets: ```python REDIS = { "tasks": {"URL": "unix:///run/redis-netbox/redis.sock?db=0", "SSL": False}, "caching": {"URL": "unix:///run/redis-netbox/redis.sock?db=1", "SSL": False}, } ``` In the case of the tasks Redis database, if and only if `URL` is defined, NetBox would use it. In the case of the caching Redis database, `URL` is always used, but defaults to the value that was used before the patch. This should be backwards compatible.
Author
Owner

@jeremystretch commented on GitHub (May 7, 2024):

@minijackson sounds good, I'll assign this to you for a PR. Thanks!

@jeremystretch commented on GitHub (May 7, 2024): @minijackson sounds good, I'll assign this to you for a PR. Thanks!
Author
Owner

@jeremystretch commented on GitHub (May 21, 2024):

@minijackson are you still interested in working on this?

@jeremystretch commented on GitHub (May 21, 2024): @minijackson are you still interested in working on this?
Author
Owner

@minijackson commented on GitHub (May 21, 2024):

Yes, sorry. Went on a quick vacation, then that task fell through the cracks. I'll submit a PR soon.

@minijackson commented on GitHub (May 21, 2024): Yes, sorry. Went on a quick vacation, then that task fell through the cracks. I'll submit a PR soon.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9588