-
Notifications
You must be signed in to change notification settings - Fork 18.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
curl only results in "Empty reply from server" #2522
Comments
Ok I'm an idiot. It was just a misconfiguration of the server to only listen on localhost. I simply never thought of it before because I always proxied with ssh -L to my servers. |
I had exactly the same issue and I was already banging my head. You just gave me the right hint to solve it. Thanks man! |
Glad I could help. Funny thing is, I don't even remember anymore what setting I was talking about here, it's a shame I didn't describe it better. |
It was good enough for me :) |
Thanks! I was getting crazy with the same issue... For people playing with GO AppEngine inside container, specify the host when launching your server instance: goapp serve -host=0.0.0.0 myapp/ If you don't specify -host=0.0.0.0 .you will not be able to query your server from outside the container, even with a good port mapping configuration at Docker level. |
+1. Got me too. 😆 |
@muellermichel @reiz @ameuret @dbenque could you please try to elaborate on the setting you are talking about? Running into the same problem but I can't figure it out. |
@ianzapolsky It's basically the same when you want to make couchdb accessible from outside your host, no matter whether it runs in a container or not: you need to bind it's address to 0.0.0.0:
|
cheers @muellermichel, thanks a lot. This solved my problem. For anyone stumbling upon this thread in the future, my specific issue was this: I am running a gunicorn server serving a Django app inside a docker container, exposing it to the host on port 8000 via |
@ianzapolsky Thanks for your comment. It helped me realise that the issue with For anyone who runs into this in future. |
@KirillGrishin Thanks for your valuable comment. My problem is also solved :). |
Basically, that tells the server to listen on all networks, not just to localhost connections, otherwise the server is only accessible from within the container (which is the local host for the server running there) |
Thank You @thaJeztah |
That's really helpful! |
Encountered the same issue building my own ElasticSearch container. Glad to see I'm not the only one. |
テスト時はhostを0.0.0.0に設定すること moby/moby#2522 ./manage.py runserver 0.0.0.0:8000
thanks, i had the same bind to localhost issue |
I love you all. the same issue trouble me a long day. |
It happened to me. The problem were two hosts with SSH forwarding to the same port on localhost. I was connecting to other host where jupyter was not running. 🤦♂️ |
Had the same issue with a python flask app doing app.run on "localhost". Fixed by changing it to "0.0.0.0" |
@muellermichel Saved me a headache as well - thank you ! Glad to see we're not alone as idiots. : ) |
I had this error but it was due to my corporate proxy server. For some reason my VM was using the proxy server to resolve localhost? |
I also have the same problem, My nodejs server is running in a docker container, it has exposed some REST endpoints, but when I make a curl request to those REST endpoints, I got below error
Solution:-
|
I'm a bit lucky that I've only been banging my head for an hour or so before I found this. Of course, the app needed to be bound to 0.0.0.0 and not 127.0.0.1. I'd already solved this problem before but the configurations on this project were not done by me. This thread gave me the answer I needed to not go insane. :D |
I did the same thing. I'm running a Flask app and all I had to do was add host='0.0.0.0' to the app.run() as a parameter for it to work properly again. |
I got the same error I had to change the configuration file in the project and rebuild the image. Before that when not in project nodejs host: process.env.HOST || '0.0.0.0', After having it my application worked |
exactly the same situation here lol |
Same problem faced and fixed. Thanks to @muellermichel. Listening on |
Thank you very much!!!! |
The same for Spring Boot applications, you need to change the property |
This helped me today as I was trying to spin up go app server in a docker container. I have to change from |
So the point is making elasticsearch server listen to |
I got this issue for the title but my problem wasn't totally related to that. As I'm using docker-compose, I need to set this variable on the
|
If I am not able to change the address from 127.0.0.1 to 0.0.0.0, is there another workaround ? |
What if I can't change from localhost to 0.0.0.0? My app needs google sign in, and inside google client services I can't put http://0.0.0.0:8080/auth/ as authorized redirect URIs because it is invalid somehow..... |
@Gavin-Hoang I posted my solution on stack overflow linked here. I basically ended up using port forwarding to solve the issue |
@michaelpulis Thank you very much. Will try it! |
Hopefully this helps someone, this post made me find my mistake: Make sure the PORT you're running the app on matches the one specified in the In my case, my node express app was running on port 5000 but I ran the command |
Almost gone insane with this problem until I found this thread. Work before containerisation with localhost 127.0.0.1 but with containerization, the IP (for hostPort) for http.ListenAndServe(hostPort, router) has to be 0.0.0.0, so as to accept any IP. |
This problem's classic, binding in docker |
is worked |
+1 this saved me a lot to time |
Thank you so much, guys! The combination of the following solved it for me: ENV GUNICORN_CMD_ARGS="--timeout 60 -k gevent -b 0.0.0.0:5001" |
For anyone else who may be stuck on this issue and is running a Spring Boot application. I found that I had a misconfiguration where I set my Tomcat port to be 8081. Which was also the same port I configured Docker to forward traffic to. In this configuration, Docker will forward traffic received on port 8081 of the host to port 8080 of the container. Since the application is not listening on port 8080 inside the Docker container, the connection is closed, and you get a "socket hang up" error. So in this case, I needed to set SERVER_PORT to 8080 for everything to work. |
I would like to thank everyone for this post, as I wasted a couple hours debugging containerizing my actix-web application. I am very very surprised Google Gemini wasn't able to diagnose this issue at all. For anyone else trying actix-web, I did this: #[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.route("/", web::get().to(anything))
.route("/health-check", web::get().to(health_check))
})
// .bind(("127.0.0.1", 8080))?
.bind(("0.0.0.0", 8000))?
.run()
.await
} |
I still haven't figured out docker networking.
The problem:
Servers I start within the container are not reachable from the host. Curl on the host respond with "curl: (52) Empty reply from server". Note that this is different behavior than trying to connect to a port that hasn't been forwarded, which would result in "curl: (56) Recv failure: Connection reset by peer". I guess since the nc tests work, I can actually send from the outside, but the container cannot seem to send. It really looks like a firewall problem, but ufw is disabled on host and in the container it's not even installed.
Any ideas?
Edit: some example
docker ps shows
on my container. Inside the container I can do:
Everything fine there. But from the host:
The text was updated successfully, but these errors were encountered: