简体   繁体   English

在 127.0.0.1:6379 (Errno::ECONNREFUSED) 上连接到 Redis 时出错 - Wercker

[英]Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) - Wercker

I'm using wercker for running specs of my rails app.我正在使用 wercker 来运行我的 rails 应用程序的规范。 I have problem with setting up redis on wercker.我在 wercker 上设置 redis 时遇到问题。 In my rails app I have redis.rb which looks like this:在我的 Rails 应用程序中,我有redis.rb看起来像这样:

if Figaro.env.rediscloud_url
  uri = URI.parse(Figaro.env.rediscloud_url)
  REDIS = Redis.new(host: uri.host, port: uri.port, password: uri.password)
elsif ENV['WERCKER_REDIS_HOST'] && ENV['WERCKER_REDIS_PORT']
  REDIS = Redis.new(host: ENV['WERCKER_REDIS_HOST'], port: ENV['WERCKER_REDIS_PORT'])
else
  REDIS = Redis.new
end

In wercker I set WERCKER_REDIS_HOST enviromental variable to: 127.0.0.1 and WERCKER_REDIS_PORT to 6379在 wercker 中,我将WERCKER_REDIS_HOST环境变量设置为: 127.0.0.1WERCKER_REDIS_PORT6379

When I start my specs it returns:当我开始我的规格时,它会返回:

 Redis::CannotConnectError:
Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:332:in `rescue in establish_connection'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:318:in `establish_connection'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:94:in `block in connect'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:280:in `with_reconnect'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:93:in `connect'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:351:in `ensure_connected'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:208:in `block in process'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:293:in `logging'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:207:in `process'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:178:in `call_pipelined'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:150:in `block in call_pipeline'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:280:in `with_reconnect'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:148:in `call_pipeline'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis.rb:2245:in `block in multi'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis.rb:57:in `block in synchronize'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis.rb:57:in `synchronize'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis.rb:2237:in `multi'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/sidekiq-4.1.0/lib/sidekiq/client.rb:171:in `block in raw_push'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:64:in `block (2 levels) in with'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:63:in `handle_interrupt'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:63:in `block in with'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:60:in `handle_interrupt'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:60:in `with'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/sidekiq-4.1.0/lib/sidekiq/client.rb:170:in `raw_push'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/sidekiq-4.1.0/lib/sidekiq/client.rb:67:in `push'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/sidekiq-4.1.0/lib/sidekiq/worker.rb:115:in `client_push'
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/sidekiq-4.1.0/lib/sidekiq/extensions/generic_proxy.rb:19:in `method_missing'
# ./app/models/user.rb:26:in `send_reset_password_instructions'
# ./spec/models/user_spec.rb:43:in `block (3 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# IO::EINPROGRESSWaitWritable:
# Operation now in progress - connect(2) would block
# /pipeline/cache/bundle-install/ruby/2.3.0/gems/redis-3.2.2/lib/redis/connection/ruby.rb:122:in `connect_addrinfo'

How can I fix that?我该如何解决?

I had the same problem, but I found a fix:我遇到了同样的问题,但我找到了解决方法:

Start Redis manually in terminal with redis-server使用redis-server在终端中手动启动 Redis

I had the same issue and the steps I used to solve this in Mac OSX Catalina were:我遇到了同样的问题,我在 Mac OSX Catalina 中用来解决这个问题的步骤是:

  1. Install redis (if not installed)安装redis(如果没有安装)
brew install redis
  1. Start the redis server (thanks @Mirror318)启动redis服务器(感谢@Mirror318)
redis-server

or to start in background或在后台启动

# By default Redis does not run as a daemon. Use 'yes' to use it
redis-server --daemonize yes

您可能还需要安装 redis-server

$ sudo apt install redis-server

确保您在系统上安装了 redis-server:-

 sudo apt install redis-server

try this one:-试试这个:-

redis-server --daemonize yes

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 rails + docker + sidekiq +错误连接到127.0.0.1:6379上的Redis(Errno :: ECONNREFUSED) - rails + docker + sidekiq + Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) (在localhost:6379(Errno :: ECONNREFUSED)上连接到Redis时出错): - (Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)): Sidekiq 在 docker-compose 上的 127.0.0.1:6379 (Errno::ECONNREFUSED) 上连接到 Redis 时出错 - Sidekiq Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) on docker-compose Rails-Redis :: CannotConnectError:在本地主机上连接Redis时出错:6379(Errno :: ECONNREFUSED) - Rails - Redis::CannotConnectError: Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED) Redis :: CannotConnectError(在localhost:6379(Errno :: ECONNREFUSED)上连接到Redis时出错): - Redis::CannotConnectError (Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)): 在 Rails 应用程序上的 127.0.0.1:6379(ECONNREFUSED) 上连接到 Redis 时出错 - Error connecting to Redis on 127.0.0.1:6379(ECONNREFUSED) on rails application 想在Heroku上使用Redis(Redis :: CannotConnectError(在127.0.0.1:6379上连接到Redis时出错(ECONNREFUSED))) - Want to use Redis on Heroku (Redis::CannotConnectError ( Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED)) ) Redis / Resque [在本地主机上连接到Redis时出错:6379(ECONNREFUSED)] - Redis/Resque [Error connecting to Redis on localhost:6379 (ECONNREFUSED)] GiLab CI-Redis :: CannotConnectError:在127.0.0.1:6379上连接到Redis时出错 - GiLab CI - Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 Sidekiq Redis :: CannotConnectError:生产时在127.0.0.1:6379上连接到Redis时出错 - Sidekiq Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 on production
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM