ngrok
ngrok copied to clipboard
Getting an error as "502 Bad Gateway"
Hi, I have installed ngrok version 2.2.8 on mac. I am trying to send http request to server using postman. A request is sending correctly. I am able to see headers in http://127.0.0.1:4040 ngrok web interface. I am getting a response as " 502 Bad Gateway. The server returned an invalid or incomplete response." How would I debug ngrok request?
This just started happening to me. Any suggestions/fixes? Nothing knowingly changed on my end as of late...
bump on this, it seems to happen when i paste it into the facebook sharing debugger
Getting this error too -- anyone resolution..?
+1. v2.2.8 running on windows 10.
+1 v2.2.8, v2.2.9, and v2.2.7 on windows server 2008. Getting this text:
502 Bad Gateway The server returned an invalid or incomplete response.
Well I am able to see localhost:4040 (which is the introspection page) through the tunnel, so its some disagreement between ngrok and my application. It'd be really nice if ngrok would log somewhere WHAT it did not like.
Try running it without ssl
Thanks @harksha -- examining the documentation for how to ;)
EDIT -- you probably mean adding -bind-tls=false -- that did not work:
Incorrect Usage: flag provided but not defined: -bind-tls
@harksha I see you posted 10 days ago that you had this problem, would appreciate figuring out which version of ngrok worked for you and what combo of command line options :)
THANKS!
@Joe118 No, I mean you need to disable ssl on your local solution, so it runs on http, not https
@harksha my http server already was running on http only.
Anyways I'm pretty convinced this is not a problem with ngrok because I can direct ngrok to forward port 4040 (its own diagnostic) and then I can see it fine on the ngrok.io subdomain. So its something to do with my http server.
I still can't figure out why the port forwarding would cause a 502, because I can see the web page when I run a web browser on the same machine and look at it via localhost:8000/index.html
@Joe118 ok, I thought that's what fixed it, but you're right, it might be port forwarding(which got stopped when I removed ssl). Don't have any idea why, tho'.
@harksha thanks!
I'm going to chat with the people who wrote the embedded web server I'm using -- EmbedIO. I'll report back here if they find anything.
@harksha and @inconshreveable I opened https://github.com/unosquare/embedio/issues/154 on the EmbedIO project's github repository.
OK its not an ngrok bug and not a bug in EmbedIO either. :)
The issue is that when you tell a webserver to serve pages on http://localhost:8787/ (as an example), some also bind http://127.0.0.1:8787/ and some do not. There's no rule that the webserver has to, but also no rule that it does NOT have to. So to be sure ngrok will tunnel your web server, you have to bind both localhost:8787 and 127.0.0.1:8787
@inconshreveable , so now the question becomes, did anything change in ngrok recently to require both localhost and 127.0.0.1 to be bound?
Hey so you will need to start your server manually so that it listens on the port you want. Run php -S 0.0.0.0:5000 -t public/ on linux command line with 5000 being the port you wanna feed to ngrok. Then go to ngrok and run ngrok http 5000
That will work
Switching the protocol from http
to tls
worked for me.
switching from http to tls killed the 502 error for me, but now i'm getting an invalid hostname 4xx error
Also getting the bad gateway for connecting to localhost running an HTTPS (TLS) server on port 9011. When switching to HTTP (not HTTPS) it works.
Any new ideas?
This is what worked for me. Spent hours searching for it. Some of the above solution didn't work. I would recommend this order. ngrok http https://localhost:5443 -host-header="localhost:5443" -subdomain=<If you have pro> ngrok http https://localhost:5443 -host-header="localhost:5443"
Ngrok expects a web server to be running on localhost. If there isn’t a server running, you’ll see a 502 error .
I also ran into the same issue with testing some webhooks locally. In my case, I had to make sure ngrok was tunneling to my local development server running on HTTPS, not HTTP.
Hi tanvish,
502 gateway error occurs because ngrok not able to receive any reponse from Localhost.
The things need to be done is : 1.Start a webserver in a Port 2.Trigger ngrok command in that Port.
What i have done is -> Started a tomcat Web Server in 8080. -> Then Triggered ngrok http 8080.
It works really Kool .. Try this .. Hope it works for You .
just use ngrok http port_number it works
For linux users w/ default port 80:
sudo apt-get install apache2
sudo service apache2 start
ngrok http 80
- Make sure port 80 is allowed through firewall
- place sample html file in
/var/www/html/index.html
Sudo not install on Android phone when i using termux .
ngrok http 8080
This works for me! :+1:
Thank you for opening this issue! As of April 2016, the ngrok service has permanently moved to https://ngrok.com/. To join the community and file bug reports or feature enhancements for the ngrok agent, please go to https://github.com/ngrok/ngrok.
This repository is no longer actively maintained and will be archived soon to reduce confusion with the latest ngrok versions. We thank you for the continued support of ngrok and look forward to seeing you over at ngrok.com and the ngrok Community Repo.