无法连接到在Docker中运行的Redis(Windows 10专业版)

xa9qqrwz  于 2023-11-16  发布在  Redis
关注(0)|答案(1)|浏览(204)

我的Redis容器遇到了一个连接问题,希望得到一些指导。下面是一个故障:
集装箱信息:

  1. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  2. edc955eceb27 redis:5 "docker-entrypoint.s…" 16 hours ago Up 2 hours 0.0.0.0:6379->6379/tcp sad_lumiere

字符串
IP地址:

  1. $ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' edc
  2. 172.17.0.2


  1. 1:C 09 Nov 2023 07:35:16.706 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
  2. 1:C 09 Nov 2023 07:35:16.707 # Redis version=5.0.14, bits=64, commit=00000000, modified=0, pid=1, just started
  3. 1:C 09 Nov 2023 07:35:16.707 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
  4. 1:M 09 Nov 2023 07:35:16.712 * Running mode=standalone, port=6379.
  5. 1:M 09 Nov 2023 07:35:16.712 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
  6. 1:M 09 Nov 2023 07:35:16.712 # Server initialized
  7. 1:M 09 Nov 2023 07:35:16.713 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
  8. 1:M 09 Nov 2023 07:35:16.714 * DB loaded from disk: 0.001 seconds
  9. 1:M 09 Nov 2023 07:35:16.714 * Ready to accept connections


故障排除步骤:
1.将IP从172.17.0.2更改为127.0.0.1
1.禁用Windows Defender
1.已验证端口6379是否通过netstat -ano | findstr "6379"打开
1.使用Python脚本进行测试,结果为TimeoutError

  1. import redis
  2. redis_client = redis.Redis(host='172.17.0.2', port=6379, decode_responses=True)
  3. redis_client.set('my_key', 'Hello, Redis!')
  4. value = redis_client.get('my_key')
  5. print(value)


输出量:

  1. TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond


1.使用Telnet测试:
C:\WINDOWS\system32>telnet 172.17.0.2 6379 Connecting To 172.17.0.2... Could not open connection to the host, on port 6379: Connect failed
我将感谢任何见解或建议。谢谢。

cuxqih21

cuxqih211#

6379/tcp,0.0.0.0:6739->6739/tcp sad_lumiere
你的port export 6739.. port export应该是'6379'而不是'6739'.
第一个月

相关问题