为远程连接打开Redis端口 [英] Open Redis port for remote connections
问题描述
我可以在服务器上 ping pong Redis:
I can ping pong Redis on the server:
# redis-cli ping
PONG
但是远程,我遇到了问题:
But remotely, I got problems:
$ src/redis-cli -h REMOTE.IP ping
Could not connect to Redis at REMOTE.IP:6379: Connection refused
在配置中,我得到了标准端口:
In config, I got the standard port:
# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
那么也许我应该在远程 Ubuntu 机器上打开端口 6379?我该怎么做?
So maybe I should open port 6379 on the remote Ubuntu machine? How do I do it?
推荐答案
您是否设置了绑定选项以允许远程访问 redis 服务器?
Did you set the bind option to allow remote access on the redis server?
之前(文件/etc/redis/redis.conf
)
bind 127.0.0.1
之后
bind 0.0.0.0
并运行 sudo service redis-server restart
重新启动服务器.如果这不是问题,您可能需要检查任何可能阻止访问的防火墙.
and run sudo service redis-server restart
to restart the server. If that's not the problem, you might want to check any firewalls that might block the access.
重要提示:如果您不使用防火墙(iptables、ufw..)来控制谁连接到正在使用的端口,则任何人都可以连接到此 Redis 实例.不使用 Redis 的 AUTH
这意味着任何人都可以访问/更改/删除您的数据.注意安全!
Important: If you don't use a firewall (iptables, ufw..) to control who connects to the port in use, ANYONE can connect to this Redis instance. Without using Redis' AUTH
that means anyone can access/change/delete your data. Be safe!
这篇关于为远程连接打开Redis端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!