当前位置: 首页 > 知识库问答 >
问题:

无法连接AWS EC2端口6379上的redis服务器

萧升
2023-03-14

我在EC2上有两个服务器。一个托管我的php应用程序,另一个托管我的redis服务器。我在redis服务器上管理我的php会话和数据。因此,在我的php服务器上,我将ip:port作为会话保存路径,并在stderr中收到了错误FastCGI:“php消息:php致命错误:未捕获异常‘redisception’,消息‘Connection closed’”

我需要在我的redis实例上为入站流量打开端口6379。我通过在AWS安全组中设置自定义TCP设置来打开它,但该端口仍然对外界关闭。但是我能够监听redis服务器本身上的端口。我在这个过程中错过了什么吗?我是否需要在某个地方进行任何其他更改。请指导我。我对AWS管理非常陌生在实例1上:我正在使用php、Apache和phpredis在实例2上:使用Redis

但我在实例2上安装了Memcached,该实例通过端口11211连接,没有任何问题。我对Redis使用了相同的安全规则

共有1个答案

梁盛
2023-03-14

默认情况下,redis只在127.0.0.1上侦听,您需要明确告诉redis侦听其他接口或任何节点。根据您的发行版,这可能是类似于redis的地方。形态。

最重要的是,如果你想让redis监听所有地址(0.0.0.0),你应该在redis.conf.

当你配置redis时,为了上帝的爱,请确保在你的安全组设置中,你定义该端口仅对需要连接到redis的PHP服务器的IP或安全组开放,而不是对整个世界开放。

作为参考,这里是redis的配置部分。关于绑定:

# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
# 
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 2) No password is configured.
#
# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
# sockets.
#
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
protected-mode yes
 类似资料:
  • 我在AWS ec2实例上设置了一个redis服务器,如下所示https://medium.com/@andrewcbass/install-redis-v3-2-on-aws-ec2-instance-93259d40a3ce 我正在另一个ec2实例上运行python脚本 在redis服务器的安全组中,我允许端口6379上的入站流量 运行上述脚本时,我遇到以下错误: 我已经尝试过更改conf文件中

  • PostgreSQL出现错误: 和文件是正常的(参见下面)。 服务器正在运行 我的文件:

  • 嗨,我正试图连接到一个redis服务器,监听AWS EC2 linux服务器上的端口6379。 我执行了以下步骤,创建了一个允许6379端口的自定义TCP入站规则,并将redis.conf bind更改为XX。XXX.XX.XXX:6379或者0.0.0.0但是还是无法连接服务器,有没有人可以帮忙。 这是我在AWS上的入站规则

  • 问题内容: 在Digitalocean的Ubuntu 16.4中安装了Redis。 我已经通过编辑编辑将默认的redis服务器更改为我在Digitalocean中的IP 那之后,我试着和所有回应这样的: 在127.0.0.1:6379无法连接到Redis的:连接被拒绝 但是如果 我得到: 这正常吗?或者该怎么办? 问题答案: 您应该做什么取决于您希望它如何工作… 如果您希望能够通过任何网络接口连接

  • null 我得到这个错误 Redis连接到127.0.0.1:6379失败-连接econn拒绝127.0.0.1:6379

  • 我的应用程序正在使用Revovit(V1.6.1)连接到REST web服务,它无法连接到我的本地web服务器(运行在)上,这是我得到的错误。 这是在Nexus4(V4.3)模拟器中,我使用Android Studio进行开发,并且在清单文件中添加了&权限。 错误说它等待了15秒,但它不是,它马上就错误了。