Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED

267,436

Solution 1

After you install redis, type from terminal:

redis-server

and you'll have redis running

Solution 2

I solve this problem in next way:

sudo apt-get install redis-server

then run command to confirm that everything ok:

sudo service redis-server status

And the output will be: redis-server is running - that means that the problem is solved.

Solution 3

Install redis on your system first -

brew install redis

then start the redis server -

redis-server

Solution 4

I'm on windows, and had to install Redis from here and then run redis-server.exe.

From the top of this SO question.

Solution 5

Simple solution:

only hit below commend once and restart your server again

redis-server
Share:
267,436

Related videos on Youtube

Huy Tran
Author by

Huy Tran

Updated on July 28, 2022

Comments

  • Huy Tran
    Huy Tran almost 2 years

    I working with node.js by expressjs
    I try to store an account to session. So, i try to test to use session with code in expressjs

    var RedisStore = require('connect-redis')(express);
    app.use(express.bodyParser());
    app.use(express.cookieParser());
    app.use(express.session({ secret: "keyboard cat", store: new RedisStore }));
    

    but I got error Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED.
    Please help me resolve this problem

    • a sad dude
      a sad dude over 12 years
      Is Redis running? Can you connect to it by other means e.g. redis-cli?
    • Huy Tran
      Huy Tran over 12 years
      Thank u, because redis server not running. I install redis-server follow this tutorial
    • Emad Aghaei
      Emad Aghaei about 6 years
      You should instal Redis server on your machine and rune it. I donot know why the author doesn't mentioned this important thing in the manual!
    • amar ghodke
      amar ghodke over 5 years
      How do I add redis-server for my node Heroku app? I also have same error.
  • Romans 8.38-39
    Romans 8.38-39 almost 10 years
    For me, I should specify the conf, so I type >> (sudo) redis-server /etc/redis/redis.conf
  • vineet
    vineet over 8 years
    that error fixed but now new error show i.e, "Error: ERR wrong number of arguments for 'set' command"
  • Dropout
    Dropout over 8 years
    Please explain your answer. It is currently viewed as a low quality post. Thanks!
  • Balakumaran
    Balakumaran over 8 years
    i got this error in ubuntu...solve with this commands..now it's working fine .....
  • Codious-JR
    Codious-JR about 8 years
    Thank you. Stupid how in the tutorial they never mentioned how to start the redis server!
  • Morteza
    Morteza about 7 years
    redis-server --daemonize yes to run in background
  • just-be-weird
    just-be-weird about 4 years
    Thanks! this resolved the issue, just a small note on Linux/WSL environments after installing re-run the command redis-server or prefix it by sudo if needed. If all goes well, you will see redis-server cli message. also can be verified by sudo service redis-server status as suggested by @author.
  • lukas_o
    lukas_o almost 4 years
    Be aware: This will take some time to run. If you have a dependency manager (brew or other) this will save you time.
  • Edison Pebojot
    Edison Pebojot about 3 years
    @morteza-ziyae How do I stop redis server in the background?
  • kiranr
    kiranr over 2 years
    thank you it fixed my issue, don't know why it is not taking port and host as input
  • MartianMartian
    MartianMartian about 2 years
    brew services start redis is better