Docker Community Forums

Share and learn in the Docker community.

Curl 400 error from external connection


(Txt3rob) #1

Hey,

i have a docker container using the base of buildpack-deps:stretch-scm on ubuntu 16.04.3 using Docker version 17.09.0-ce, build afdb6d4

I have a nodejs server running inside the container and everytime i do a curl request to it i get a 400 error.

curl -i  http://192.168.1.71

HTTP/1.1 400 Bad Request
Content-Type: text/plain;charset=utf-8
Connection: close
Server: httpd.js
Date: Tue, 24 Oct 2017 21:28:14 GMT
Content-Length: 12

Bad request

if i do the request to localhost inside the container the script works but if i do it externally either the docker up or the main host ip it still does the same

this appears to be some weird header issue has any one got any ideas or seen this before?


(Txt3rob) #2

Fixed… had to stop the system from listening on 0.0.0.0 in the container and change it to the docker internal IP


(David Maze) #3

While I’m not sure what your problem is, as a general rule servers running in Docker containers should listen on 0.0.0.0, and as a general rule you never need a container’s Docker-internal IP address for anything.

Looking at the docker logs of the running container might be informative, as might curl -v to show more detailed HTTP header information.