【问题标题】:Unable to connect to redis server deployed on Amazon ec2 on port 6379无法连接到部署在 Amazon ec2 上的端口 6379 上的 redis 服务器
【发布时间】:2017-09-04 00:54:42
【问题描述】:

我已经在 https://medium.com/@andrewcbass/install-redis-v3-2-on-aws-ec2-instance-93259d40a3ce 之后的 AWS ec2 实例上设置了一个 redis 服务器

我正在另一个 ec2 实例上运行 python 脚本

import redis

try:
    conn = redis.Redis(host=<private ip address>,port=6379, db=1)
    user = {"Name":"Pradeep", "Company":"SCTL", "Address":"Mumbai", "Location":"RCP"}
    conn.hmset("pythonDict", user)
    conn.hgetall("pythonDict")
except Exception as e:
    print(e)

在redis服务器的安全组中,我已经允许6379端口的入站流量

在运行上述脚本时,我收到以下错误:

Error 111 connecting to 172.31.22.71:6379. Connection refused.

我已经尝试更改 conf 文件中的绑定值,正如一些关于堆栈溢出的类似问题的答案所建议的那样,但它没有工作

【问题讨论】:

  • 临时修改您的安全组以允许来自客户端的所有出站流量和所有到 Redis 服务器的入站流量。可以连接吗?

标签: python amazon-web-services amazon-ec2 redis


【解决方案1】:

假设您的其他实例与 Redis 实例位于同一子网中,我的建议是检查以下几件事:

  1. 确保在您的安全组入站规则中,您已为子网设置了 Redis 端口,例如:

    6379 (REDIS)    172.31.16.0/20
    
  2. 从您的Redis 配置(例如/etc/redis/redis.conf)中,如果尚未完成,请将服务器绑定到私有IP(bind 172.31.22.71)或简单地注释掉任何现有的本地主机绑定,然后重启Redis

【讨论】:

    猜你喜欢
    • 2017-05-11
    • 1970-01-01
    • 2020-09-30
    • 2014-04-14
    • 2012-12-26
    • 2012-06-08
    • 1970-01-01
    • 2018-03-23
    • 1970-01-01
    相关资源
    最近更新 更多