sysadmin umesh
sysadmin umesh

Reputation: 49

curl (56) Recv failure: Connection reset by peer - when hitting docker container

getting this error while curl the application ip

curl (56) Recv failure: Connection reset by peer - when hitting docker container

Upvotes: 4

Views: 16494

Answers (3)

sysadmin umesh
sysadmin umesh

Reputation: 49

I GOT the same error:

umesh@ubuntu:~/projects1$ curl -i localhost:49161

curl: (56) Recv failure: Connection reset by peer

In my case it was due wrong port no

|---MY Projects--my working folder

--------|Dockerfile ---port defined 8080

--------|index.js-----port defined ***3000*** 

--------|package.json

Then i was running:

docker run -p 49160:8080 -d umesh1/node-web-app1**

So as the application was running in port 3000 in index.js it was not able to connect to the application got the error as u were getting

So TO SOLVE THE PROBLEM

Deleted the last container/image that was created my worong port

Just change the port no of INDEX.JS

|---MY Projects--my working folder

--------|Dockerfile ---port defined 8080

--------|index.js-----port defined ***8080***

--------|package.json

Then build the new image

docker build -t umesh1/node-web-app1 .

running the image in daemon mode with exposed port

docker run -p 49160:8080 -d umesh1/node-web-app1

THUS MY APPLICATION WAS RUNNING without any error listing on port 49161

Upvotes: 0

Tomasz Bartkowiak
Tomasz Bartkowiak

Reputation: 14958

Do a small check by running:

docker run --network host -d <image>

if curl works well with this setting, please make sure that:

  1. You're mapping the host port to the container's port correctly:
docker run -p host_port:container_port <image>
  1. Your service application (running in the container) is running on localhost or 0.0.0.0 and not something like 127.0.0.1

Upvotes: 4

Ryabchenko Alexander
Ryabchenko Alexander

Reputation: 12380

I have same when bind to port that is not lissened by any service inside container. So check -p option

-p 9200:9265
-p <port in container>:<port in host os to be binded to>

Upvotes: -1

Related Questions