Error Connecting to Redis on 127.0.0.1:6379 (Errno::Econnrefused) - Wercker

Sidekiq Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) on docker-compose

Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)

Your app tries to connect on the localhost interface of the container it is running in, but redis is running in a different container.

Modify your app config to use the link name of the redis container (redis in your case) as hostname for the connection.

redis fails to connect in rails (ECONNREFUSED)

Perhaps, what you are looking to do is run your redis-server in the background.

The Easy Way(Tm)

redis-server &

The Proper Way(Tm)

# cd into your redis directory(path for mine on OSX below)
cd /usr/local/etc/redis.conf
vim redis.conf
daemonize yes # find this line and change 'no' to 'yes'

Then restart your redis server.

Also, here are helpful instructions specific to OSX(if that's your platform):
https://medium.com/@petehouston/install-and-config-redis-on-mac-os-x-via-homebrew-eb8df9a4f298#.mc9tqg22p

Trying to connect to Redis returns an ECONNREFUSED

The configuration you described is not being used by your application:

REDIS_URL=redis://redis:6379

When you see the connection run, it's trying to connect to 127.0.0.1 instead of the container ip:

Error: connect ECONNREFUSED 127.0.0.1:6379

To solve this, you'll need to reconfigure your app so that it uses the redis DNS name instead of 127.0.0.1. Each container has its own private loopback interface, so connecting to this inside a container will connect to the container itself, not your host or any other container running on the host.

As an aside, do not use links. They have been deprecated. The built in DNS will give name resolution to the service name. If you have dependencies between containers, it's best to handle this in the application or entrypoint. You can also use depends_on to list service dependencies, but this only works with docker-compose, and does not verify the health of the dependent services.



Related Topics



Leave a reply



Submit