Sidekiq worker repeatedly crashing after deploy with "Connection refused... for 127.0.0.1:6379"

Project ID: 2637570f-afaf-462c-887b-912303121dfd Service: 63bb6b2e-042f-443b-a46c-7d34958bd347 - Rails 7.0.7 app (using Jumpstart Pro) - Ruby 3.2.2 - App boots fine, but before long the Worker crashes with the following message:
Connection refused - connect(2) for 127.0.0.1:6379
/usr/local/lib/ruby/3.2.0/socket.rb:1217:in `__connect_nonblock'
/usr/local/lib/ruby/3.2.0/socket.rb:1217:in `connect_nonblock'
/usr/local/lib/ruby/3.2.0/socket.rb:60:in `connect_internal'
/usr/local/lib/ruby/3.2.0/socket.rb:141:in `connect'
/usr/local/lib/ruby/3.2.0/socket.rb:645:in `block in tcp'
/usr/local/lib/ruby/3.2.0/socket.rb:231:in `each'
/usr/local/lib/ruby/3.2.0/socket.rb:231:in `foreach'
/usr/local/lib/ruby/3.2.0/socket.rb:635:in `tcp'
Connection refused - connect(2) for 127.0.0.1:6379
/usr/local/lib/ruby/3.2.0/socket.rb:1217:in `__connect_nonblock'
/usr/local/lib/ruby/3.2.0/socket.rb:1217:in `connect_nonblock'
/usr/local/lib/ruby/3.2.0/socket.rb:60:in `connect_internal'
/usr/local/lib/ruby/3.2.0/socket.rb:141:in `connect'
/usr/local/lib/ruby/3.2.0/socket.rb:645:in `block in tcp'
/usr/local/lib/ruby/3.2.0/socket.rb:231:in `each'
/usr/local/lib/ruby/3.2.0/socket.rb:231:in `foreach'
/usr/local/lib/ruby/3.2.0/socket.rb:635:in `tcp'
- I have the REDIS_URL set on the Web service - I imported the repo from Github directly
20 Replies
Percy
Percy15mo ago
Project ID: 2637570f-afaf-462c-887b-912303121dfd,63bb6b2e-042f-443b-a46c-7d34958bd347
Brody
Brody15mo ago
looks like you are trying to connect to a local redis database, if you are wanting to connect to a redis database on railway make sure you have the reference variables setup on your service correctly https://docs.railway.app/develop/variables#reference-variables and make sure you are using those environment variables in code properly
Estafette
EstafetteOP15mo ago
I have the REDIS_URL set on the worker but it doesn't seem to be picking it up.
Brody
Brody15mo ago
show me your service variables please
Estafette
EstafetteOP15mo ago
On the worker, I'm currrently trying this:
{"REDIS_URL":"${{web.REDIS_URL}}"}
{"REDIS_URL":"${{web.REDIS_URL}}"}
But I also tried redis.REDIS_URL (which was provided by the redis instance I'm running) The web.REDIS_URL is apparently an empty string
Brody
Brody15mo ago
sorry i should have been a little more clear, so can get the best understanding of how you have things configured at the service level, please provide me with a screenshot of your service variables with the redis url variable visible
Estafette
EstafetteOP15mo ago
I just re-deployed and tried adding the Postgres database URL - it's green in the screenshot, but it literally just crashed again
No description
Estafette
EstafetteOP15mo ago
No description
Brody
Brody15mo ago
your redis reference variable is incorrect, please take a look at this docs section https://docs.railway.app/develop/variables#reference-variables
Estafette
EstafetteOP15mo ago
I'll try this one again
No description
Brody
Brody15mo ago
okay now show me the redis service variables please
Estafette
EstafetteOP15mo ago
No description
Brody
Brody15mo ago
looks good show me how you are using the REDIS_URL environment variable in code
Estafette
EstafetteOP15mo ago
Worker seems stable now
Brody
Brody15mo ago
oh then all good
Estafette
EstafetteOP15mo ago
There's a few places where we're using <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> Thanks for your help @Brody !
Brody
Brody15mo ago
no problem!
danielfriis
danielfriis12mo ago
@Estafette How did you get a sidekiq worker up and running? It doesn't seem like worker is supported in the procfile
Estafette
EstafetteOP12mo ago
I ended up just bailing on it entirely. It would reboot and be stable for a bit, then inevitably crash. My app isn’t using Sidekiq just yet, so I can live without it in the interim
Brody
Brody12mo ago
quick little bit of info here, railway does not support worker processes defined in the Procfile, that is a heroku specific thing. instead you would want to deploy another railway service to run the worker processes, essentially that involves deploying a duplicate service and then setting the start command accordingly in the service settings
Want results from more Discord servers?
Add your server