使用自制程序安装Redis,但当我尝试ping Redis时,它显示这个错误:
Could not connect to Redis at 127.0.0.1:6379: Connection refused
注意: 我尝试关闭防火墙并编辑conf文件,但仍然无法ping通。 我使用的是macOS Sierra和自制版本1.1.11
使用自制程序安装Redis,但当我尝试ping Redis时,它显示这个错误:
Could not connect to Redis at 127.0.0.1:6379: Connection refused
注意: 我尝试关闭防火墙并编辑conf文件,但仍然无法ping通。 我使用的是macOS Sierra和自制版本1.1.11
当前回答
我使用的是Ubuntu 18.04 我刚刚在CMD中输入了这个命令 Sudo systemctl start redis-server 现在它正在发挥作用。所以我认为我的redis服务器没有启动,为什么它显示我的错误 无法连接到Redis 127.0.0.1:6379:连接被拒绝。
其他回答
在我的情况下,有人来了,并错误地编辑redis.conf文件如下:
bind 127.0.0.1 ::1
bind 192.168.1.7
当,它真的需要这样(一行):
bind 127.0.0.1 ::1 192.168.1.7
我使用的是Ubuntu 18.04 我刚刚在CMD中输入了这个命令 Sudo systemctl start redis-server 现在它正在发挥作用。所以我认为我的redis服务器没有启动,为什么它显示我的错误 无法连接到Redis 127.0.0.1:6379:连接被拒绝。
日期:2021年12月
这个错误有几个原因。我读了一篇文章来解决这个问题。所以我就逐一总结一下要检查什么。
1检查:Redis-Server未启动
redis-server
Also to run Redis in the background, the following command could be used.
redis-server --daemonize yes
2. 检查:防火墙限制
sudo ufw status (inactive)
sudo ufw active (for making active it might disable ssh when first time active. So enable port 22 to access ssh.)
sudo ufw allow 22
sudo ufw allow 6379
3.检查:资源使用情况
ps -aux | grep redis
4. 配置设置限制
sudo vi /etc/redis/redis.conf.
注释下面的行。
# bind 127.0.0.1 ::1
注意:恶意行为者将更难发出请求或访问您的服务器。确保您绑定到正确的IP地址网络。
希望它能帮助到别人。欲了解更多信息,请阅读下面的文章。
https://bobcares.com/blog/could-not-connect-to-redis-connection-refused/
我刚刚遇到了同样的问题,因为我在配置文件中使用了不正确的语法。我想补充一点:
maxmemory-policy allkeys-lru
到我的配置文件中,但只添加了:
allkeys-lru
这显然阻止了Redis解析配置文件,这反过来又阻止了我通过cli连接。修正这个语法可以让我连接到Redis。
Mac版Redis:
1-酿造安装redis 2-酿造服务启动redis 3- redis-cli ping
$ brew services start redis
$ brew services stop redis
$ brew services restart redis
午餐自动启动选项:
$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
# autostart activate
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
# autostart deactivate
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Redis conf默认路径:/usr/local/etc/redis.conf