Fatal error: Uncaught exception 'RedisException' with message 'Redis server went away'
Asked Answered
P

6

7

One of my application suddenly started to give error:

Fatal error: Uncaught exception 'RedisException' with message 'Redis server went away' in /var/www/_slim/_core/system/generator.001.php:133 Stack trace: #0 /var/www/_slim/_core/system/generator.001.php(133): Redis->auth('77B1BFFBC0378DF...') #1 /var/www/_slim/_core/system/generator.007.php(144): Generator001->r6_redis_start('R') #2 /var/www/_slim/_core/system/generator.007.php(26): Generator007->HarvestRedis() #3 /var/www/_slim/_core/system/generator.shopping.php(14): Generator007->Generator007() #4 /var/www/_slim/_core/system/generator.last.php(43): Generator008->Generator008() #5 /var/www/_slim/site/home/php/index.php(16): GeneratorLast->GeneratorLast() #6 /var/www/index.php(96): Gui->Gui()
#7 {main} thrown in /var/www/_slim/_core/system/generator.001.php on line 133

I have reinstalled redis-server but no luck so far. Any suggestions?

Pretorius answered 27/7, 2014 at 20:8 Comment(0)
M
4

Well, as the exception describes itself, your Redis server is down.

Try the following stuff:

  1. See if the server that runs the Redis instance contains any firewall on (iptables, maybe?).
  2. Go to your web server (that runs your php) and try to telnet to your redis server.
  3. See if the configured host/ip is correct. Maybe something in the network settings of the Redis server have been changed.
Mohandis answered 27/7, 2014 at 20:12 Comment(3)
(1) tried by disabling iptables but no luck (2). How can I telnet to your redis server. I am using lighttpd. (3). See if the configured host/ip is correct. Maybe something in the network settings of the Redis server have been changed. - How can I do that? I guess it's ok.Pretorius
Connect to the server that runs your applications via ssh, and just do: telnet yourRedisHost 6379 (or whatever is the port you configured). See if connection is established. 3 - Check your app config, where you have configured your redis host/ip:port, to see if its matches your current production stateMohandis
Telnet connected.. even connecting through core php but not with ZF2. Please helpLauryn
I
12

Maybe not the answer to the specific question, but might help those new to Redis who come here by googling the Exception.

You will also get this exception if you create a Redis instance and start to call methods on it without first connecting to a Redis server by calling

$redis->connect('localhost')

The arguments for the call should obviously be adjusted if Redis is not a local host, configured to listen on a different port, set up a password etc.

Instant answered 19/10, 2015 at 15:12 Comment(2)
I am using it with ZF2 and there is no way to connect it manually.. as its getting connected by itself. Still getting this error.Lauryn
@Lauryn I am not using ZF, but hope either one of the answers might help - check if the Redis server is actually is not down and that you are passing correct details to the StorageFactory or whatever is creating a Redis instance.Instant
M
4

Well, as the exception describes itself, your Redis server is down.

Try the following stuff:

  1. See if the server that runs the Redis instance contains any firewall on (iptables, maybe?).
  2. Go to your web server (that runs your php) and try to telnet to your redis server.
  3. See if the configured host/ip is correct. Maybe something in the network settings of the Redis server have been changed.
Mohandis answered 27/7, 2014 at 20:12 Comment(3)
(1) tried by disabling iptables but no luck (2). How can I telnet to your redis server. I am using lighttpd. (3). See if the configured host/ip is correct. Maybe something in the network settings of the Redis server have been changed. - How can I do that? I guess it's ok.Pretorius
Connect to the server that runs your applications via ssh, and just do: telnet yourRedisHost 6379 (or whatever is the port you configured). See if connection is established. 3 - Check your app config, where you have configured your redis host/ip:port, to see if its matches your current production stateMohandis
Telnet connected.. even connecting through core php but not with ZF2. Please helpLauryn
L
4

I had a problem connecting to the redis

I managed to solve it by changing the colon to a comma

$redis->connect('localhost:6379');

from this to this

$redis->connect('localhost', 6379);
Lemmy answered 2/3, 2019 at 15:30 Comment(0)
G
1

If you are running on a local/dev environment, make sure that Redis Service is running.

You can check if your local service is running by opening the Redis Client cmd. If you are on a MAC open the command line and type redis-cli.

If your server is running you should see:

redis 127.0.0.1:6379>

In my case I forgot to start the windows service so all I had to do was to: open services.msc, start Redis Server service.

Glennieglennis answered 3/4, 2017 at 13:44 Comment(0)
B
0

I've had the same issue when integrating my software with local Redis installation. Turned out "localhost" host name was not resolved (stuff was was running in a docker container which didn't know that). Changed it to regular loopback IP "127.0.0.1" in the client config and it rolls.

Bercy answered 16/2, 2022 at 22:48 Comment(0)
C
0

My issue was that I was using Docker Compose and needed to use the name of the container instead of 'localhost'.

// Connect to the Redis Docker created server. 'redis' refers to the
// 'redis' container in the docker-compose.yml file.
$redis->connect('redis');
// docker-compose.yml
redis:
    image: redis:alpine
    volumes:
        - redis-data:/data
    ports:
        - ${FORWARD_REDIS_PORT:-6379}:6379
    healthcheck:
        test: ["CMD", "redis-cli", "ping"]
    networks:
        - default
Chinn answered 2/9, 2022 at 14:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.