Curl 400 error from external connection


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/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?

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

While I’m not sure what your problem is, as a general rule servers running in Docker containers should listen on, 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.