Read Error When Accessing Local Server with wget

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 LISTEN

It 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 5000 in your Dockerfile.
  • You can add --expose 5000 to your docker run command
  • You can add -p 5000:5000 to your docker run command

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like