Redis connection to 127.0.0.1:6379 failed – connect ECONNREFUSED

Redis connection to 127.0.0.1:6379 failed – connect ECONNREFUSED

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

Solutions/Answers:

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

Solution 6:

I also have the same problem, first I tried to restart redis-server by sudo service restart but the problem still remained. Then I removed redis-server by sudo apt-get purge redis-server and install it again by sudo apt-get install redis-server and then the redis was working again. It also worth to have a look at redis log which located in here /var/log/redis/redis-server.log