Redis Unix Socket, Ubuntu Install

I am trying to install Discourse, I configured my db, redis, and smtp. For the Postgresql DB it had no problem with the unix socket, but for redis it seems to be complaining.

redis settings:

sudo sed -i 's/^# unixsocket /unixsocket /' /etc/redis/redis.conf
sudo sed -i 's/^# unixsocketp.*/unixsocketperm 770/' /etc/redis/redis.conf
sudo sed -i 's/^# maxmemory <bytes>/maxmemory 1024mb/' /etc/redis/redis.conf
sudo sed -i 's/^# maxmemory-policy noeviction/maxmemory-policy allkeys-lru/' /etc/redis/redis.conf
sudo cat /etc/redis/redis.conf | grep "^maxmemory\|^unixsocket"

configure redis socket:
nano /var/www/discourse/config/discourse.conf
redis_host = "/var/run/redis/redis-server.sock"

During Discourse Install:

RAILS_ENV=production /root/.rbenv/versions/2.7.2/bin/bundle exec rake db:migrate

Failed to report error: Error connecting to Redis on localhost:///var/run/redis/redis-server.sock:6379 (SocketError) 2 Error connecting to Redis on localhost:///var/run/redis/redis-server.sock:6379 (SocketError
) subscribe failed, reconnecting in 1 second. Call stack ["/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:362:in `rescue in establish_connection'", "/var/www/discourse/vendor/b
undle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:343:in `establish_connection'", "/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:107:in `block in connect'", "/var/www/disc
ourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:308:in `with_reconnect'", "/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:106:in `connect'", "/var/www/disco
urse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:289:in `with_socket_timeout'", "/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:139:in `call_loop'", "/var/www
/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/subscribe.rb:44:in `subscription'", "/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/subscribe.rb:14:in `subscribe'", "/var/
www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis.rb:3506:in `_subscription'", "/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis.rb:2326:in `block in subscribe'", "/var/www
/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis.rb:69:in `block in synchronize'", "/root/.rbenv/versions/2.7.2/lib/ruby/2.7.0/monitor.rb:202:in `synchronize'", "/root/.rbenv/versions/2.7.2/lib/ru
by/2.7.0/monitor.rb:202:in `mon_synchronize'", "/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis.rb:69:in `synchronize'", "/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/
redis.rb:2325:in `subscribe'", "/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/message_bus-3.3.1/lib/message_bus/backends/redis.rb:287:in `global_subscribe'", "/var/www/discourse/vendor/bundle/ruby/2.7.0/gems
/message_bus-3.3.1/lib/message_bus.rb:754:in `global_subscribe_thread'", "/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/message_bus-3.3.1/lib/message_bus.rb:702:in `block in new_subscriber_thread'"]
rake aborted!
Redis::CannotConnectError: Error connecting to Redis on localhost:///var/run/redis/redis-server.sock:6379 (SocketError)
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:362:in `rescue in establish_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:343:in `establish_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:107:in `block in connect'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:308:in `with_reconnect'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:106:in `connect'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:381:in `ensure_connected'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:233:in `block in process'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:320:in `logging'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:232:in `process'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis/client.rb:126:in `call'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis.rb:557:in `block in del'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis.rb:69:in `block in synchronize'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis.rb:69:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/redis-4.2.1/lib/redis.rb:556:in `del'
/var/www/discourse/lib/discourse_redis.rb:81:in `block in del'
/var/www/discourse/lib/discourse_redis.rb:29:in `ignore_readonly'
/var/www/discourse/lib/discourse_redis.rb:79:in `del'
/var/www/discourse/lib/cache.rb:73:in `delete'

If you want to install Discourse for production you should use the Discourse official Standard Installation. If you want to install a development environment, there are topics for each os.

1 Like

Thank you for the reply.

Just to clarify, I am completely up and running and everything working, but I had to set redis host to “localhost” because connecting to redis via unix socket would not work.

I followed this guide: Install Discourse Forum on Ubuntu 18.04 Without Docker
because the guide is somewhat dated I did have to make a couple adjustments here and there, but I am very familiar with Linux so I was able to work through it just fine.

My install is on a Proxmox LXC container running Ubuntu 20.04

I don’t find many references online about using Redis via UnixSocket, I am wondering if that might be somewhat new for redis, I did find a link but it appears they are using docker and I am not so its not directly applicable: Discourse PR for redis.socketed.template.yml - Discourse System Administration - Unix Linux Community

1 Like

Then you’ll mostly be on your own, as only the Discourse official Standard Installation is supported here.

I think that it’ll be rather difficult to install or maintain a production instance that does not use Docker. There are a number of tricky bits with the interaction between nginx and Discourse that will be complicated to maintain withtout the docker container that they provide, but anything’s possible, I suppose.

yes, luckily they provide a sample nginx config

/var/www/discourse/config/nginx.sample.conf

From what I am reading not even the docker image supports redis through unix socket yet.

That’s not likely to change. If the current template doesn’t support using a socket than that means CDCK doesn’t use a redis socket in their hosting or their supported docker installation.

I’m not sure what problem you’re solving by not using the supported ./launcher & docker configuration, but you’re likely going to find a bunch of other issues as well.

I am not sure if you have ever used Proxmox, but in my opinion it is Fantastic! I can log into the web interface and with a single click create a backup, I can then make changes and if something goes wrong I just select the backup and click restore.

Then on top of that you get much better performance from an LXC container than you will from a docker image, there is no comparison.

I am not saying docker is bad because as you have pointed out it makes it VERY easy to get setup.

I bet for the things you’ve used it for it’s been great!

I’m pretty sure that people have made that comparison and that 100-1000X as many images are running on Docker than on LXC (which I did use, once upon a time).

I’m not saying that Proxmox is bad, but if you want Discourse to be easy to set up and maintain, you’ll use Docker. For a frame of reference, if you were to ask for help on marketplace with a budget of under $1,000 I wouldn’t respond.

The point of the thread was to ask about the current status of Redis Unix Socket. Not to debate if LXC or docker is better suited for Discourse. I only mentioned why I was not using Docker because you seemed like you might be curious about it. For the average person docker will win every time, because its simple. That is also the reason that for the longest time so many applications used mysql instead of postgresql. But I absolutely love postgresql.

Until I run into some kind of devastating problems I will definitely be sticking with LXC, it just performs great! Also I couldn’t agree more that if you think you might need external support that you should probably stick with whatever the recommended defaults are. I myself have 20 different services all in their own LXC containers, running in a single Proxmox node, and they are all running great, and that is just a single Node in a Proxmox Cluster. Automated backups, Monitoring, Migration between Nodes in the cluster, these are all great things :slight_smile:

Did I mention that my install went smoothly? So far I love Discourse, other than having to use localhost for redis instead of unix socket I had zero issues, will try and remember to post back in a few months to let you know if that is still the case :wink:

2 Likes

Ha! NO! Awesome! Glad you got it worked out! It sounds like if you’re willing to live with localhost for redis you’ll be trouble free going forward.

I guess it’s usermod -aG redis discourse or alternatively unixsocketperm 777 so that unicorn has permissions to access the socket. Also assure that the directory where the socket is to be created exists and has redis user as owner. However, the common systemd-service based redis-server package on Ubuntu assures that.