打开Redis端口进行远程连接 [英] Open Redis port for remote connections
问题描述
我可以在服务器上乒乓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屋!