Cannot assign requested address - connect(2) for [::1]:6379
chrisvel opened this issue · 12 comments
I added Gush in a Rails app along with Sidekiq.
I have added the Gushfile and the 'gush' queue to the sidekiq.yml. When I try to start a workflow I am getting strange Redis errors:
Errno::EADDRNOTAVAIL in NetworksController#create
Cannot assign requested address - connect(2) for [::1]:6379
I know I am missing something but what?
Looks like your app can't connect to Redis, did you configure it?
This is an app I've been working successfully for months. Something changed with the installation of the gem and I can't figure out what. I need to mention that I am using Rails/Sidekiq/Postgres/Redis in docker containers with docker-compose.
Did you update the gem? What version are you using now and what version was before? I can't really help with fixing bugs in your own app that is unrelated to the gem. How do you configure Redis client in your app? It seems it tries to use ipv6, is it expected?
In Sidekiq config.redis = { url: (ENV["REDIS_URL"] || 'redis://localhost:6379/1') }
and in docker-compose REDIS_URL: 'redis://redis:6379/1'
. The thing is that If I uninstall the gem, sidekiq jobs function just fine.
What does your gushfile look like?
require_relative './config/environment.rb'
## wrongly added there
config.autoload_paths += ["#{Rails.root}/app/jobs", "#{Rails.root}/app/workflows"]
This is incorrect, the config.autoload_paths does not go into Gushfile, please check this section again carefully: https://github.com/chaps-io/gush#ruby-on-rails
That was a foolish thing to do :(
Restarted the rails server but I don't see any change. I guess the Gushfile has to go in the Rails root along with the Gemfile etc.
Alright, so please try configuring redis url directly for Gush like described here:
https://github.com/chaps-io/gush#cleaning-up-afterwards
basically, create a new initializer with:
Gush.configure do |config|
config.redis_url = ENV["REDIS_URL"] || 'redis://localhost:6379/1'
end
This should make the Gush client aware which Redis server to connect to
It works. I see you hardcoded the redis hostname to localhost ? It took me some time to figure out it has to be the name of the container for docker, but again using an environmental variable is safer.
The ENV["REDIS_URL"] || 'redis://localhost:6379/1'
comes from your snippet above. But yeah localhost is a fallback if you don't provide your own.
https://github.com/chaps-io/gush/blob/master/lib/gush/configuration.rb#L12
As you can imagine, the gem cannot possibly guess where you run your Redis server, that's why the configuration exists :)
I haven't read the cleanup section to be honest. We may update the readme with adding the initialiser to the top If you agree. Thanks for helping.