# Discourse Container with UnixSocket for Redis?

**URL:** <https://meta.discourse.org/t/discourse-container-with-unixsocket-for-redis/153945>\
**Category:** Self-hosting\
**Created:** [June 5, 2020, 1:53pm UTC](https://meta.discourse.org/t/discourse-container-with-unixsocket-for-redis/153945 "2020-06-05T13:53:40Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![MichaIng](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaing/32/251089_2.png) [@MichaIng](https://meta.discourse.org/u/MichaIng)\
**Post date:** [May 12, 2025, 6:43pm UTC](https://meta.discourse.org/t/discourse-container-with-unixsocket-for-redis/153945/7 "2025-05-12T18:43:01Z")

</div>

Did anyone else recognize that `REDIS_URL` has no effect anymore? During (re)build and as well at container start, despite `REDIS_URL` set to connect via UNIX socket, it tries to connect to via `redis://localhost:6379`.

On the one hand, it makes sense, since Discourse has configs for and applies host and port only: [discourse/app/models/global\_setting.rb at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/main/app/models/global_setting.rb#L208-L209)  
There would be a `path` parameter to define a UNIX socket path, which would override host and port. And there would be a `url` parameter, to define a full URL like `unix:///shared/redis_data/redis.sock`.

The Redis gem documents that the `REDIS_URL` environment variable would override any other settings, and until a certain Discourse/Redis gem version this worked: [redis-rb/lib/redis.rb at master · redis/redis-rb · GitHub](https://github.com/redis/redis-rb/blob/master/lib/redis.rb#L39-L75)

UNIX socket usage broke when Discourse moved to the Redis gems version 5: [DEV: Upgrade the Redis gem to v5.4 · discourse/discourse@2ed31fe · GitHub](https://github.com/discourse/discourse/commit/2ed31fe)  
So I guess `REDIS_URL` broke in the Redis gem (not overriding other options anymore), and not by Discourse (where the related code did not change)?

Likely this commit broke it: [Use redis-client as transport · redis/redis-rb@08a2100 · GitHub](https://github.com/redis/redis-rb/commit/08a2100)  
I would report it at the Redis gem repo, or does someone know it is an issue with how Discourse implements it?

The environment variable btw is passed correctly. I left it in place and only configured Redis to not listen on the UNIX socket, and while unicorn starts up nicely, sidekiq fails, missing the UNIX socket instead 😅:

```plaintext
Error in demon processes heartbeat check: No such file or directory - connect(2) for /shared/redis_data/redis.sock
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/redis-client-0.24.0/lib/redis_client/ruby_connection.rb:116:in `initialize'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/redis-client-0.24.0/lib/redis_client/ruby_connection.rb:116:in `new'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/redis-client-0.24.0/lib/redis_client/ruby_connection.rb:116:in `connect'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/redis-client-0.24.0/lib/redis_client/ruby_connection.rb:51:in `initialize'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/redis-client-0.24.0/lib/redis_client.rb:759:in `new'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/redis-client-0.24.0/lib/redis_client.rb:759:in `block in connect'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/redis-client-0.24.0/lib/redis_client/middlewares.rb:12:in `connect'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/redis-client-0.24.0/lib/redis_client.rb:758:in `connect'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/redis-client-0.24.0/lib/redis_client.rb:745:in `raw_connection'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/redis-client-0.24.0/lib/redis_client.rb:705:in `ensure_connected'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/redis-client-0.24.0/lib/redis_client.rb:285:in `call'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-7.3.9/lib/sidekiq/redis_client_adapter.rb:36:in `block (2 levels) in <module:CompatMethods>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-7.3.9/lib/sidekiq/api.rb:912:in `block in cleanup'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-7.3.9/lib/sidekiq/config.rb:175:in `block in redis'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/connection_pool-2.5.3/lib/connection_pool.rb:110:in `block (2 levels) in with'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/connection_pool-2.5.3/lib/connection_pool.rb:109:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/connection_pool-2.5.3/lib/connection_pool.rb:109:in `block in with'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/connection_pool-2.5.3/lib/connection_pool.rb:106:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/connection_pool-2.5.3/lib/connection_pool.rb:106:in `with'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-7.3.9/lib/sidekiq/config.rb:172:in `redis'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-7.3.9/lib/sidekiq.rb:74:in `redis'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-7.3.9/lib/sidekiq/api.rb:912:in `cleanup'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/sidekiq-7.3.9/lib/sidekiq/api.rb:903:in `initialize'
/var/www/discourse/lib/demon/sidekiq.rb:25:in `new'
/var/www/discourse/lib/demon/sidekiq.rb:25:in `heartbeat_check'
config/unicorn.conf.rb:131:in `block (2 levels) in reload'

```

It fits into the picture that `REDIS_URL` still works, but only if connection settings are not defined otherwise. Looking at the error trace, `global_setting.rb` does not apply host and port for sidekiq, like it does for unicorn.

---

_[View the full topic](https://meta.discourse.org/t/discourse-container-with-unixsocket-for-redis/153945)._
