与redis的连接正在超时

时间:2013-02-27 01:09:19

标签: redis

$ redis-cli -h ec2-75-101-204-XXX.compute-1.amazonaws.com
Could not connect to Redis at ec2-75-101-204-XXX.compute-1.amazonaws.com:6379: Operation timed out

这就是我从主机获得的东西。我在该机器上设置了安全组,以便对端口6379开放。

当我在redis服务器上运行netstat时,我发现它正在监听:

$ netstat -nlp
(No info could be read for "-p": geteuid()=1000 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -               
tcp6       0      0 :::22                   :::*                    LISTEN      -               
udp        0      0 0.0.0.0:68              0.0.0.0:*                           -               
Active UNIX domain sockets (only servers)

我的redis.conf看起来像是:

daemonize yes
pidfile /var/run/redis.pid
port 6379
timeout 300
loglevel notice
logfile /var/log/redis.log
databases 16

save 900 1
save 300 10
save 60 10000

stop-writes-on-bgsave-error yes
rdbcompression yes

那么我为什么要从另一台机器上超时?

1 个答案:

答案 0 :(得分:10)

redis仅侦听localhost端口:127.0.0.1:6379

您需要将redis配置为0.0.0.0上的绑定。

在redis.conf中的

(最有可能在/etc/redis/redis.conf,替换(或添加,如果不存在)

bind 127.0.0.1

bind 0.0.0.0