GiLab CI - Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379

Tony Vincent

Few tests are failing in pipeline with error Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED).

My .gitlab-ci.yml file

image: starefossen/ruby-node:latest

services:
  - mongo:latest
  - redis:latest

variables:
  MONGODB_URI: mongodb://mongo:27017/db_test
  REDISTOGO_URL: redis://localhost:6379

before_script:
  - bundle install --path=cache/bundler
  - cp config/mongoid.yml.gitlab config/mongoid.yml
  - RAILS_ENV=test bundle exec rake db:create db:migrate

test:
  script:
   - bundle exec rake test

my config/initializers/sidekiq.rb file

require 'sidekiq'
require 'sidekiq-status'

Sidekiq.configure_client do |config|
  config.redis = { size: 5, url: ENV['REDISTOGO_URL'] }
end

Sidekiq.configure_server do |config|
  config.server_middleware do |chain|
    chain.add Sidekiq::Throttler, storage: :redis
  end
  config.redis = { size: 10, url: ENV['REDISTOGO_URL'] }
end

can anyone point me the right direction? Thank you

nattfodd

There's no one single localhost in Docker which is used by Gitlab CI. The convention is that the service name declared below will be available for other containers in the docker network by it's name - redis in that case:

services:
  - redis:latest

So replacing localhost with redis should be enough:

variables:
-   REDISTOGO_URL: redis://localhost:6379
+   REDISTOGO_URL: redis://redis:6379

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

When connecting to Java socket, why does getInetAddress() return /0:0:0:0:0:0:0:1?

RedisInsight on Docker and Redis on Docker: Could not connect: Error 99 connecting to localhost:6379. Cannot assign requested address

redis.exceptions.ConnectionError: Error -2 connecting to localhost:6379. Name or service not known

Decrement score in Redis or remove if 0

Heroku RedisCloud Redis::CannotConnectError on localhost instead of REDISCLOUD_URL

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

Redis error: Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379

Cannot connect to redis://localhost:6379/0: Error 99 connecting to localhost:6379. Cannot assign requested address

Name or service not known [tcp://redis:6379]

rails + docker + sidekiq + Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)

docker-compose error connecting to redis + sidekiq

Could not connect to Redis at 127.0.0.1:6379: Connection refused

Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379 nodejs

Nodejs app not connecting to redis in amazon ecs task definition. getaddrinfo ENOTFOUND redis redis:6379

docker-compose + django + redis - Error 111 connecting to 127.0.0.1:6379. Connection refused

Using Resque-Scheduler with Docker-Compose - Error connecting to Redis on localhost:6379

Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379 Heroku

Error occured with redis HMSEET, dial tcp :6379: connect: connection refused

Fail to connect to Redis in Kubernetes: Redis connection to localhost:6379 failed

what is the purpose of db=0 when connecting to redis server in python?

Rails 5 error connecting to Redis on Heroku

Error connecting Celery to Redis when using Docker

Error when connecting to redis docker container

redis.exceptions.ConnectionError: Error 99 connecting to localhost:6379. Cannot assign requested address

AWS Elastic Cache Redis Cluster `MOVED XXXXX ip:6379` error

Error -2 connecting to redis://redis:6379:6379. Name or service not known

Error dial tcp 127.0.0.1:6379: connect: connection refused when starting Redis container without Docker Compose

Error -3 connecting to redis:6379. Temporary failure in name resolution

Redis at some-redis:6379: Name or service not known