Home > Article > Backend Development > uncaught exception redisexception with message Connection closed
When running redis in LNMP environment, the following error occurs: "PHP Fatal error: Uncaught exception 'RedisException' with message 'Connection closed' in". How to solve it?
Specific question: When running redis in LNMP environment, the following error "PHP Fatal error: Uncaught exception 'RedisException' with message 'Connection closed' in" appears. How to solve it?
The best adopted answer:
I just encountered this problem today. The solutions found online (such as setting connection timeout, etc.) are invalid. Solve it yourself and then answer it:
Redis check---- -------------------------->
1. Check whether the redis service is started: ps -ef | grep redis
2. OK The port number that redis runs on: such as the default 6379
3, telnet 127.0.0.1 6379. If the connection fails, check the firewall settings and open port 6379
4. Redis configuration check: timeout 0 (no timeout) in redis.conf, bind 127.0.0.1 (If redis is not used locally, configure the user machine IP for ip, or set it directly to 0.0.0.0 without restrictions)
PHP setting check---------------- -------------->
1. Determine whether PHP has the redis extension installed: extension = redis.so has been configured in php.ini, and redis.so exists
2. Check the php.ini file: default_socket_timeout = 600 (unit is s, set at least 60s)
The most important thing, if you use redis to manage sessions, then check the php.ini file:
session.save_handler = redis
session .save_path = "tcp://127.0.0.1:6379" (The redis ip and port here must be set correctly!)
[Related tutorial recommendations]
Online free video tutorials:Redis video tutorial