在 Linux redis 验证交互连接过程中遇到 redis Could not connect to Redis at 127.0.0.1:6379: Connection refused 的解决方法

时间:2023-03-09 09:12:27
在 Linux    redis 验证交互连接过程中遇到 redis   Could not connect to Redis at 127.0.0.1:6379: Connection refused  的解决方法

Could not connect to Redis at 127.0.0.1:6379: Connection refused

在 Linux    redis 验证交互连接过程中遇到 redis   Could not connect to Redis at 127.0.0.1:6379: Connection refused  的解决方法

1.找到redis.conf 并修改 daemonize no 为 daemonize yes ,这样就可以默认启动就后台运行

[root@ trade01  conf.d]# vi /etc/redis.conf

在 Linux    redis 验证交互连接过程中遇到 redis   Could not connect to Redis at 127.0.0.1:6379: Connection refused  的解决方法

2.开启客户端要确保服务端启动

[root@ trade01 src]# ./redis-server ../etc/redis.conf

现在就可以正常访问了

[root@ trade01 src]# ./redis-cli

redis 127.0.0.1:6379>set foo bar

OK
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379>

如果还是报错

查看配置文件,发现bind是写成:

bind 127.0.0.1

修改配置为

bind  192.168.0.129

192.168.0.129是redis所在的服务器的地址

再次启动

(如果把 bind 127.0.0.1 修改为了 192.168.0.129 启动若是不成功 就把 127.0.0.1加上去

在 Linux    redis 验证交互连接过程中遇到 redis   Could not connect to Redis at 127.0.0.1:6379: Connection refused  的解决方法

两个地址之间要空格隔开)