Ошибка redis connection failed

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

O. Jones's user avatar

O. Jones

102k17 gold badges118 silver badges171 bronze badges

asked Jan 6, 2012 at 6:40

Huy Tran's user avatar

4

After you install redis, type from terminal:

redis-server

and you’ll have redis running

answered Jun 21, 2012 at 23:16

piggyback's user avatar

piggybackpiggyback

8,97413 gold badges50 silver badges80 bronze badges

4

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.

Loolooii's user avatar

Loolooii

8,54114 gold badges65 silver badges90 bronze badges

answered Jan 27, 2015 at 6:16

cn007b's user avatar

cn007bcn007b

16.5k7 gold badges59 silver badges73 bronze badges

2

Install redis on your system first —

brew install redis

then start the redis server —

redis-server

answered Aug 3, 2016 at 5:40

Partha Roy's user avatar

Partha RoyPartha Roy

1,57515 silver badges16 bronze badges

1

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

From the top of this SO question.

Community's user avatar

answered Feb 4, 2015 at 2:36

Felix's user avatar

FelixFelix

3,7235 gold badges34 silver badges52 bronze badges

0

For those of you who are using docker with docker-compose and Typescript my solution was

import { RedisClient } from 'redis';

 const pubClient = new RedisClient({ url: 'redis://redis:6379' });

to

import { createClient } from 'redis';

const pubClient = createClient({ url: 'redis://redis:6379' });

docker-compose.yml

version: '3.9'

services:
  main:
    build:
      context: .
      target: development
    ports:
      - ${PORT}:${PORT}
    volumes:
      - ./src:/usr/src/app/src
      - /app/node_modules
    env_file:
      - .env
    command: npm run start:dev
    depends_on:
      - mongo
      - redis
  mongo:
    image: mongo:5.0.2-focal
    volumes:
      - mongo-data:/data/db
  mongo-express:
    image: mongo-express:0.54.0
    ports:
      - 8081:8081
    depends_on:
      - mongo
  redis:
    image: redis:6.2.5-alpine

volumes:
  mongo-data:

answered Aug 20, 2021 at 4:42

goodonion's user avatar

goodoniongoodonion

1,33911 silver badges25 bronze badges

1

Simple solution:

only hit below commend once and restart your server again

redis-server

answered Oct 9, 2018 at 9:39

Shashwat Gupta's user avatar

Using Windows 10?
Go here: https://learn.microsoft.com/en-us/windows/wsl/wsl2-install

Then run…

    $ wget https://github.com/antirez/redis/archive/5.0.5.tar.gz <- change this to whatever Redis version you want (https://github.com/antirez/redis/releases)
    $ tar xzf redis-5.0.5.tar.gz
    $ cd redis-5.0.5
    $ make

answered Dec 9, 2018 at 8:58

buycanna.io's user avatar

buycanna.iobuycanna.io

1,15616 silver badges18 bronze badges

for Windows users, you can use chocolatey to install Redis

choco install redis-64

then run server from

C:ProgramDatachocolateylibredis-64redis-server.exe

answered Jun 8, 2018 at 8:27

Barış Serkan AKIN's user avatar

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

answered Jul 15, 2014 at 13:32

Sadegh's user avatar

SadeghSadegh

2,6691 gold badge23 silver badges26 bronze badges

I used ubuntu 12.04
I solved that problem by installing redis-server

redis-server installation for ubuntu 12.04

some configuration will new root permission
Also listed manuals for other OS

Thanks

answered Mar 29, 2014 at 4:41

Paing Soe Thaw's user avatar

0

For me I had this issue on Ubuntu 18.x, but my problem was that my redis-server was running on 127.0.0.1 but I found out I needed to run it on my IP address xxx.xx.xx.xx

I went into my Ubuntu machine and did the following.

cd /etc/redis/

sudo vim redis.conf

Then I edited this part.

################################## NETWORK #####################################

# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 loopback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).le to listen to just one or multiple selected interfaces using
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# bind 127.0.0.1 ::1 10.0.0.1
bind 127.0.0.1 ::1 # <<-------- change this to what your iP address is something like (bind 192.168.2.2)

Save that, and then restart redis-server.

sudo service redis-server restart or simply run redis-server

answered Jul 28, 2020 at 22:57

haron68's user avatar

haron68haron68

7411 gold badge4 silver badges19 bronze badges

For windows platform, You must check if redis-server is running on given ip:port. you can find redis configuration at installation directory /conf/redis.conf. by default client accept 127.0.0.1:6379.

answered Sep 21, 2013 at 6:14

Aman Gupta's user avatar

Aman GuptaAman Gupta

5,50810 gold badges51 silver badges88 bronze badges

I’m on MBP , and install redis detail my problem was resolved .Fixed the
Download, extract and compile Redis with:

$ wget http://download.redis.io/releases/redis-3.0.2.tar.gz

$ tar xzf redis-3.0.2.tar.gz

$ cd redis-3.0.2

$ make

The binaries that are now compiled are available in the src directory.

Run Redis with:

$ src/redis-server 

Stewartside's user avatar

Stewartside

20.2k12 gold badges59 silver badges80 bronze badges

answered Jun 16, 2015 at 10:46

Halilertekin's user avatar

0

I think maybe you installed redis by source code.If that you need locate to redis-source-code-path/utils and run sudo install_server.sh command.
After that, make sure redis-server has been running as a service for your system
sudo service redis-server status

PS: based on Debian/Ubuntu

answered Apr 25, 2016 at 7:07

sudoz's user avatar

sudozsudoz

3,2151 gold badge21 silver badges19 bronze badges

In case of ubuntu, the error is due to redis-server not being set up.
Install the redis-server again and then check for the status.

If there is no error, then a message like this would be displayed :-

● redis-server.service — Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2018-01-17 20:07:27 IST; 16s ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Main PID: 4327 (redis-server)
CGroup: /system.slice/redis-server.service
└─4327 /usr/bin/redis-server 127.0.0.1:6379

answered Jan 17, 2018 at 14:46

Yadnesh Sawant's user avatar

You have to install redis server first;

You can install redis server on mac by following step —

  $ curl -O http://download.redis.io/redis-stable.tar.gz
  $ tar xzvf redis-stable.tar.gz
  $ cd redis-stable
  $ make
  $ make test
  $ sudo make install
  $ redis-server

Good luck.

Dev's user avatar

Dev

1,5321 gold badge21 silver badges43 bronze badges

answered Sep 9, 2018 at 6:32

Saiful Islam Sajib's user avatar

1

Your connection to redis is failing. Try restarting your redis server, then starting up your client again by running these 3 commands:

sudo service redis-server restart
redis-server
redis-cli

Barett's user avatar

Barett

5,8076 gold badges50 silver badges55 bronze badges

answered Jan 20, 2016 at 13:34

Balakumaran's user avatar

2

For Windows I solved this by…

using…

let redisClient = createClient({
  legacyMode: true ,
  url: 'redis://redis:6379',
});

Its for redis version > 4.0
You can refer to the image below.

1

vimuth's user avatar

vimuth

4,95630 gold badges78 silver badges115 bronze badges

answered Aug 5, 2022 at 3:58

Tarang Verma's user avatar

If your project runs on windows,

  1. You must setup and run redis-server on your windows.
  2. Run ‘npm i redis’ in your project
    It will work correctly

answered Apr 10 at 8:16

Maryam's user avatar

2

Try upgrading your node to latest version.

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

version 0.4 may not work properly.

rzymek's user avatar

rzymek

9,0032 gold badges45 silver badges59 bronze badges

answered Aug 7, 2013 at 8:38

Vaisakh VM's user avatar

Vaisakh VMVaisakh VM

1,06111 silver badges9 bronze badges

0

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

O. Jones's user avatar

O. Jones

102k17 gold badges118 silver badges171 bronze badges

asked Jan 6, 2012 at 6:40

Huy Tran's user avatar

4

After you install redis, type from terminal:

redis-server

and you’ll have redis running

answered Jun 21, 2012 at 23:16

piggyback's user avatar

piggybackpiggyback

8,97413 gold badges50 silver badges80 bronze badges

4

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.

Loolooii's user avatar

Loolooii

8,54114 gold badges65 silver badges90 bronze badges

answered Jan 27, 2015 at 6:16

cn007b's user avatar

cn007bcn007b

16.5k7 gold badges59 silver badges73 bronze badges

2

Install redis on your system first —

brew install redis

then start the redis server —

redis-server

answered Aug 3, 2016 at 5:40

Partha Roy's user avatar

Partha RoyPartha Roy

1,57515 silver badges16 bronze badges

1

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

From the top of this SO question.

Community's user avatar

answered Feb 4, 2015 at 2:36

Felix's user avatar

FelixFelix

3,7235 gold badges34 silver badges52 bronze badges

0

For those of you who are using docker with docker-compose and Typescript my solution was

import { RedisClient } from 'redis';

 const pubClient = new RedisClient({ url: 'redis://redis:6379' });

to

import { createClient } from 'redis';

const pubClient = createClient({ url: 'redis://redis:6379' });

docker-compose.yml

version: '3.9'

services:
  main:
    build:
      context: .
      target: development
    ports:
      - ${PORT}:${PORT}
    volumes:
      - ./src:/usr/src/app/src
      - /app/node_modules
    env_file:
      - .env
    command: npm run start:dev
    depends_on:
      - mongo
      - redis
  mongo:
    image: mongo:5.0.2-focal
    volumes:
      - mongo-data:/data/db
  mongo-express:
    image: mongo-express:0.54.0
    ports:
      - 8081:8081
    depends_on:
      - mongo
  redis:
    image: redis:6.2.5-alpine

volumes:
  mongo-data:

answered Aug 20, 2021 at 4:42

goodonion's user avatar

goodoniongoodonion

1,33911 silver badges25 bronze badges

1

Simple solution:

only hit below commend once and restart your server again

redis-server

answered Oct 9, 2018 at 9:39

Shashwat Gupta's user avatar

Using Windows 10?
Go here: https://learn.microsoft.com/en-us/windows/wsl/wsl2-install

Then run…

    $ wget https://github.com/antirez/redis/archive/5.0.5.tar.gz <- change this to whatever Redis version you want (https://github.com/antirez/redis/releases)
    $ tar xzf redis-5.0.5.tar.gz
    $ cd redis-5.0.5
    $ make

answered Dec 9, 2018 at 8:58

buycanna.io's user avatar

buycanna.iobuycanna.io

1,15616 silver badges18 bronze badges

for Windows users, you can use chocolatey to install Redis

choco install redis-64

then run server from

C:ProgramDatachocolateylibredis-64redis-server.exe

answered Jun 8, 2018 at 8:27

Barış Serkan AKIN's user avatar

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

answered Jul 15, 2014 at 13:32

Sadegh's user avatar

SadeghSadegh

2,6691 gold badge23 silver badges26 bronze badges

I used ubuntu 12.04
I solved that problem by installing redis-server

redis-server installation for ubuntu 12.04

some configuration will new root permission
Also listed manuals for other OS

Thanks

answered Mar 29, 2014 at 4:41

Paing Soe Thaw's user avatar

0

For me I had this issue on Ubuntu 18.x, but my problem was that my redis-server was running on 127.0.0.1 but I found out I needed to run it on my IP address xxx.xx.xx.xx

I went into my Ubuntu machine and did the following.

cd /etc/redis/

sudo vim redis.conf

Then I edited this part.

################################## NETWORK #####################################

# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 loopback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).le to listen to just one or multiple selected interfaces using
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# bind 127.0.0.1 ::1 10.0.0.1
bind 127.0.0.1 ::1 # <<-------- change this to what your iP address is something like (bind 192.168.2.2)

Save that, and then restart redis-server.

sudo service redis-server restart or simply run redis-server

answered Jul 28, 2020 at 22:57

haron68's user avatar

haron68haron68

7411 gold badge4 silver badges19 bronze badges

For windows platform, You must check if redis-server is running on given ip:port. you can find redis configuration at installation directory /conf/redis.conf. by default client accept 127.0.0.1:6379.

answered Sep 21, 2013 at 6:14

Aman Gupta's user avatar

Aman GuptaAman Gupta

5,50810 gold badges51 silver badges88 bronze badges

I’m on MBP , and install redis detail my problem was resolved .Fixed the
Download, extract and compile Redis with:

$ wget http://download.redis.io/releases/redis-3.0.2.tar.gz

$ tar xzf redis-3.0.2.tar.gz

$ cd redis-3.0.2

$ make

The binaries that are now compiled are available in the src directory.

Run Redis with:

$ src/redis-server 

Stewartside's user avatar

Stewartside

20.2k12 gold badges59 silver badges80 bronze badges

answered Jun 16, 2015 at 10:46

Halilertekin's user avatar

0

I think maybe you installed redis by source code.If that you need locate to redis-source-code-path/utils and run sudo install_server.sh command.
After that, make sure redis-server has been running as a service for your system
sudo service redis-server status

PS: based on Debian/Ubuntu

answered Apr 25, 2016 at 7:07

sudoz's user avatar

sudozsudoz

3,2151 gold badge21 silver badges19 bronze badges

In case of ubuntu, the error is due to redis-server not being set up.
Install the redis-server again and then check for the status.

If there is no error, then a message like this would be displayed :-

● redis-server.service — Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2018-01-17 20:07:27 IST; 16s ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Main PID: 4327 (redis-server)
CGroup: /system.slice/redis-server.service
└─4327 /usr/bin/redis-server 127.0.0.1:6379

answered Jan 17, 2018 at 14:46

Yadnesh Sawant's user avatar

You have to install redis server first;

You can install redis server on mac by following step —

  $ curl -O http://download.redis.io/redis-stable.tar.gz
  $ tar xzvf redis-stable.tar.gz
  $ cd redis-stable
  $ make
  $ make test
  $ sudo make install
  $ redis-server

Good luck.

Dev's user avatar

Dev

1,5321 gold badge21 silver badges43 bronze badges

answered Sep 9, 2018 at 6:32

Saiful Islam Sajib's user avatar

1

Your connection to redis is failing. Try restarting your redis server, then starting up your client again by running these 3 commands:

sudo service redis-server restart
redis-server
redis-cli

Barett's user avatar

Barett

5,8076 gold badges50 silver badges55 bronze badges

answered Jan 20, 2016 at 13:34

Balakumaran's user avatar

2

For Windows I solved this by…

using…

let redisClient = createClient({
  legacyMode: true ,
  url: 'redis://redis:6379',
});

Its for redis version > 4.0
You can refer to the image below.

1

vimuth's user avatar

vimuth

4,95630 gold badges78 silver badges115 bronze badges

answered Aug 5, 2022 at 3:58

Tarang Verma's user avatar

If your project runs on windows,

  1. You must setup and run redis-server on your windows.
  2. Run ‘npm i redis’ in your project
    It will work correctly

answered Apr 10 at 8:16

Maryam's user avatar

2

Try upgrading your node to latest version.

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

version 0.4 may not work properly.

rzymek's user avatar

rzymek

9,0032 gold badges45 silver badges59 bronze badges

answered Aug 7, 2013 at 8:38

Vaisakh VM's user avatar

Vaisakh VMVaisakh VM

1,06111 silver badges9 bronze badges

0

Could not connect to redis connection refused

Most webmasters and web hosts that use Redis would have seen this error:
Could not connect to Redis at 127.0.0.1:6379: Connection refused

It is usually caused when the Redis service is stopped in the server.

As part of our Server Management Services for online service providers and website owners, we have seen several other causes for this error.

Today we’ll go through the top causes and fixes for the Redis connection refused error.

What causes Redis connection refused error?

Redis is used by many to reduce application load time. However, users at times complain that they receive a connection refused error after installing the Redis extension.

The common reasons that trigger the error include:

  • Redis-Server not Started
  • Firewall Restriction
  • Resource usage

Apart from these, there are some alternate reasons that trigger the Redis connection error. Today, let’s look into the reasons for could not connect to Redis connection refused error and its fixes.

Redis-Server is not started

The most common reason for the connection refused error is that the Redis-Server is not started.

Redis server should be started to use the Redis client after its installation. It can be done with the following command.

redis-server

Also to run Redis in the background, following command could be used.

redis-server --daemonize yes

Firewall restriction

Firewall restriction is another common reason that can trigger the “could not connect to Redis connection refused”.

By default Redis server listen to the TCP port 6379. If another application is using the port or if the firewall restrictions blocks the port, it can trigger the connection refused error.

Thus it is important to check the status of the port in the firewall configuration while troubleshooting the could not connect to Redis error.

Resource usage 

As we discussed earlier, Redis uses the main memory to store the data. Thus if the resource in the server is not sufficient for the process to run, it may get terminated abruptly.

When the status of the Redis process is down, it triggers the could not connect to Redis error. We could confirm if it actually running using the ps command.

ps -aux | grep redis

Our Support Engineers analyzes the Redis log file to confirm if the service is repeatedly flapping in the server. From a simultaneous analysis of other log files, we confirm if any other process is consuming resources in the server and is causing Redis to terminate.

Alternate reasons

Apart from the reasons mentioned above some settings in the Redis configuration file could also result in the connection failed error. The default location for the configuration file in Ubuntu 18 is  /etc/redis/redis.conf.

Some of the reasons that may trigger the connection refused error include:

  • The password set in the Redis configuration file. To fix it, comment the following line.
#requirepass 
  • If the IP binding is not open for access from the internet in the config. Commenting the following lines will fix the issue.
# bind 127.0.0.1 ::1
[Are you struggling with Redis errors? We’ll fix it right away.]

Conclusion

In short, a number of reasons can trigger the Redis connection refused error. This ranges from firewall restrictions to resource limitations. Today we discussed how our Support Engineers fixes the error in each scenario.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = «owonCMyG5nEQ0aD71QM»;

I’m having same issue:

CLIENT: 3.0.2
REDIS: 5.0.3

  • Running within Docker / node:14.15.4-alpine3.12
  • Running Inside GCLOUD ( latency ~10ms )
  • After started, the app starts PINGING the redis server every 30 seconds
  • Server crashes after 4 minutes (usually), just after PING Bugs/multibulk zero null #8 ( PING timestamp === ERROR timestamp )
  • not a single event es registered in the log ( end, error, uncaughtException, reconnecting )
  • I’ve tried ECHO instead of PING but I got same results.
var redis__create_ping = ( client ) => {
        client.ping = setInterval(( )=>{
                let timestamp = ( new Date() ).getTime();
                client.instance.ping(  (error, pong ) => {
                        if( error ){
                                console.error( 'n<PING ERROR>', client.name, client.index );
                                console.error( error );
                        }
                        else {
                                if( __.DEBUG ){
                                        console.log( 'n<PING>', client.name, client.index, (new Date()).getTime() - timestamp );
                                }
                        };
                });
        },  30000);
};

var redis__connect = ( args , success, fail ) => {
        let { index, name } = args;
        let client = { name, index };
        let host = ___.REDIS.HOST;
        let port = ___.REDIS.PORT;
        let cli = redis.createClient({ host, port, db: index, socket_keepalive: true });
        cli.on('connect',  ready => {
                if( __.DEBUG ) console.info('n<CONNECT>', name, index  );
                client.instance = cli;
                redis__create_ping( client );
                CLIENTS[name] = client;
                success( true );
        });

        cli.on('ready', () => {
                if( __.DEBUG ) console.info( 'n<READY>', name, index );
        });

        cli.on('reconnecting', () => {
                if( __.DEBUG ) console.info( 'n<RECONNECTING>', name, index );
        });

        cli.on('end', () => {
                if( __.DEBUG ) console.info('n<END>', name, index  );
        });

        cli.on('uncaughtException',  error  => {
                console.error('n<UNCAUGHT-EXCEPTION>', name, index  );
                console.error( error  );
        });

        cli.on('error', error => {
                console.error('n<ERROR>', name, index  );
                console.error( error );
        });
};

LOG

...
2021-01-27 15:59:42.472 EST<PING> REDIS_CLIENT_BLOCKED_NUMBERS_WRITE 11 4
Default
2021-01-27 15:59:42.480 ESTevents.js:292
Default
2021-01-27 15:59:42.480 EST throw er; // Unhandled 'error' event
Default
2021-01-27 15:59:42.480 EST ^
Default
2021-01-27 15:59:42.480 EST
Default
2021-01-27 15:59:42.480 ESTError: read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
Default
2021-01-27 15:59:42.480 ESTEmitted 'error' event on RedisClient instance at:
Default
2021-01-27 15:59:42.480 EST at RedisClient.on_error (/opt/app/node_modules/redis/index.js:341:14)
Default
2021-01-27 15:59:42.480 EST at Socket.<anonymous> (/opt/app/node_modules/redis/index.js:222:14)
Default
2021-01-27 15:59:42.480 EST at Socket.emit (events.js:315:20)
Default
2021-01-27 15:59:42.480 EST at emitErrorNT (internal/streams/destroy.js:106:8)
Default
2021-01-27 15:59:42.480 EST at emitErrorCloseNT (internal/streams/destroy.js:74:3)
Default
2021-01-27 15:59:42.480 EST at processTicksAndRejections (internal/process/task_queues.js:80:21) {
Default
2021-01-27 15:59:42.480 EST errno: -104,
Default
2021-01-27 15:59:42.480 EST code: 'ECONNRESET',
Default
2021-01-27 15:59:42.480 EST syscall: 'read'
Default
2021-01-27 15:59:42.480 EST}
Warning
2021-01-27 15:59:46.579 ESTContainer called exit(1).

Could not connect to redis connection refused

Most webmasters and web hosts that use Redis would have seen this error:
Could not connect to Redis at 127.0.0.1:6379: Connection refused

It is usually caused when the Redis service is stopped in the server.

As part of our Server Management Services for online service providers and website owners, we have seen several other causes for this error.

Today we’ll go through the top causes and fixes for the Redis connection refused error.

What causes Redis connection refused error?

Redis is used by many to reduce application load time. However, users at times complain that they receive a connection refused error after installing the Redis extension.

The common reasons that trigger the error include:

  • Redis-Server not Started
  • Firewall Restriction
  • Resource usage

Apart from these, there are some alternate reasons that trigger the Redis connection error. Today, let’s look into the reasons for could not connect to Redis connection refused error and its fixes.

Redis-Server is not started

The most common reason for the connection refused error is that the Redis-Server is not started.

Redis server should be started to use the Redis client after its installation. It can be done with the following command.

redis-server

Also to run Redis in the background, following command could be used.

redis-server --daemonize yes

Firewall restriction

Firewall restriction is another common reason that can trigger the “could not connect to Redis connection refused”.

By default Redis server listen to the TCP port 6379. If another application is using the port or if the firewall restrictions blocks the port, it can trigger the connection refused error.

Thus it is important to check the status of the port in the firewall configuration while troubleshooting the could not connect to Redis error.

Resource usage 

As we discussed earlier, Redis uses the main memory to store the data. Thus if the resource in the server is not sufficient for the process to run, it may get terminated abruptly.

When the status of the Redis process is down, it triggers the could not connect to Redis error. We could confirm if it actually running using the ps command.

ps -aux | grep redis

Our Support Engineers analyzes the Redis log file to confirm if the service is repeatedly flapping in the server. From a simultaneous analysis of other log files, we confirm if any other process is consuming resources in the server and is causing Redis to terminate.

Alternate reasons

Apart from the reasons mentioned above some settings in the Redis configuration file could also result in the connection failed error. The default location for the configuration file in Ubuntu 18 is  /etc/redis/redis.conf.

Some of the reasons that may trigger the connection refused error include:

  • The password set in the Redis configuration file. To fix it, comment the following line.
#requirepass <some pass if any>
  • If the IP binding is not open for access from the internet in the config. Commenting the following lines will fix the issue.
# bind 127.0.0.1 ::1
[Are you struggling with Redis errors? We’ll fix it right away.]

Conclusion

In short, a number of reasons can trigger the Redis connection refused error. This ranges from firewall restrictions to resource limitations. Today we discussed how our Support Engineers fixes the error in each scenario.

The post Could not connect to redis connection refused – Fix it easily appeared first on Bobcares.

  • Ошибка redhorn 4800002 far cry 5
  • Ошибка red dead redemption 2 при загрузке обновления
  • Ошибка red dead redemption 2 недостаточно виртуальной памяти увеличьте размер файла подкачки
  • Ошибка red alert 3 installation not found
  • Ошибка red alert 2 fatal error