I have a node app running on port 5000 (from a docker container), but I am unable to access it.
I tried running wget after shelling into the server but I get the following error:
--2021-09-09 18:44:44--
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)
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 3 1 Answer
On the server, check that something is listening on port 5000
netstat -anp --tcp | grep 5000 | grep LISTENIt should tell you that something is listening to 127.0.0.1:5000 or 0.0.0.0:5000. The former is a loopback address (only accessible inside the server) and the latter is ANY interface on the server that has an IP (so its accessible outside the server if the local firewall allows it).
If nothing is listening on 5000, then likely the docker container is not exposing the ports.
- You can put
EXPOSE 5000in your Dockerfile. - You can add
--expose 5000to yourdocker runcommand - You can add
-p 5000:5000to yourdocker runcommand
If you can access port 5000 when you run it on your local computer, it might be working because you have added an environment variable to auto-expose the port.
2