【发布时间】:2021-09-10 01:17:10
【问题描述】:
我有一个节点应用程序在端口 5000 上运行(来自 docker 容器),但我无法访问它。
我在进入服务器后尝试运行wget http://localhost:5000,但出现以下错误:
--2021-09-09 18:44:44-- http://localhost:5000/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:5000... connected.
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.
Retrying.
--2021-09-09 18:45:17-- (try: 2) http://localhost:5000/
Connecting to localhost (localhost)|::1|:5000... connected.
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.
Retrying.```
When I run the container on my local computer, I have no trouble accessing it this way, so I'm guessing it's something on the server, but I don't know where to look next.
EDITS
Output of `sudo netstat -anp --tcp | grep 5000 | grep LISTEN`
tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN 16480/docker-proxy
tcp6 0 0 :::5000 :::* LISTEN 16486/docker-proxy
【问题讨论】:
-
可能有几个问题需要指出。向我们提供更多详细信息。它可能是您的
port mapping[ --port 3000:3000 ] 才能正常工作。 -
检查并正确暴露端口,添加了 netstat 输出的更新
-
当您的服务器位于
127.0.0.1或localhost时,有时会发生这种情况。将其更改为0.0.0.0。或至少,删除默认服务器位置。更重要的是,您还可以操纵IPv6。 在你的操作系统中禁用 IPv6。让我知道它是否正常工作。给我看你的服务器文件和Dockerfile|docker-compose.yaml如果可能的话。