LoginSignup
4
0

More than 3 years have passed since last update.

【Docker】 Redis で Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379 と出てきたときの対処法

Posted at

エラー内容

Dockerで構築したRedisにNode.jsからアクセスしようとしたら以下のようなエラーがでた

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

原因

Redisに接続するときのデフォルトはローカルホストを参照するように出来ているのでコンテナに接続することが出来ない

対処法

Node.jsからアクセスする際に直接ホストを指定してあげる

app.js
const redis = require('redis')
const client = redis.createClient(6379, 'redis')
4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0