Ngrok Errors "502 Bad Gateway"

A completely new approach to using any applications for web applications, and I tried to slowly create a Facebook Messenger bonus. When I try to use ngrok, I cannot visit the address I give, i.e.

ngrok http 5000 

- this is what I put on the command line and it returns this:

 ngrok by @inconshreveable Session Status online Version 2.1.18 Region United States (us) Web Interface http://127.0.0.1:4040 Forwarding http://ea986ca5.ngrok.io -> localhost:5000 Forwarding https://ea986ca5.ngrok.io -> localhost:5000 Connections ttl opn rt1 rt5 p50 p90 0 0 0.00 0.00 0.00 0.00 

But when I take the address https://ea986ca5.ngrok.io ', as required on the Facebook developers page, it says:

 The connection to http://ea986ca5.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:5000. Make sure that a web service is running on localhost:5000 and that it is a valid address. The error encountered was: dial tcp [::1]:5000: connectex: No connection could be made because the target machine actively refused it. 

Is this a problem with my local port? Thanks!

+26
source share
10 answers

Just like @ njzk2 should have said if you don't have a web server, so it can't work. I would like to clarify if you are still confused.

What ngrok does is make your local server (running on the local host) accessible to the outside world (the rest of the Internet). This in itself is not a web server. So, for your bot development, you need to have a web server running on a specific port (which in your case is 5000). You can then point ngrok to this port so that it redirects requests sent to your shared address to a program running on that port. The web server then receives and processes requests from Facebook.

+18
source

It worked for me

ngrok.exe http -host-header = rewrite localhost:

For example, ngrok.exe http -host-header = rewrite localhost: 5219

Im using visual studio 2017 does not know if this is affecting something.

+17
source

Try as shown below:

ngrok http 127.0.0.1:8080 -host-header="127.0.0.1:8080"

+3
source

If you are trying to use ngrok to specify the URL of the local https host, install a proxy server.

see this comment on the github issue

https://github.com/inconshreveable/ngrok/issues/448#issuecomment-414214242

+2
source

In my case, it was a project in Visual Studio 2017. Net Core 2.1 was created to use https with a self-signed certificate. If you do not need a local host for https, then for me it helped to create a new web project and uncheck https. When you run ngrok (ngrok http port-number-from-IISExpress), it provides you with https URLs that you can use for development.

+2
source

This error may occur if you have an HTTP rule to redirect HTTP to HTTPS.

You can disable this for your developer machine or add a custom rule based on the X-Original-Host header:

I am using the IIS rewrite plugin and this is how I fixed it.

  <rule name="Redirect to https" enabled="true" patternSyntax="ECMAScript" stopProcessing="true"> <match url=".*" negate="false" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTPS}" pattern="off" /> <add input="{HTTP_X_Original_Host}" pattern="yourngrokname.ngrok.io" negate="true" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" /> </rule> 
0
source

For me, switching the protocol from http to tls worked, since I only forward the secure connection. I did not need to rewrite the title.

Just for context, I'm forwarding a connection to a running dock container in Ubuntu 16.

PS: You are still accessing the address using https in the browser, not tls.

0
source

Try explicitly specifying the local IP address:

ngrok http 127.0.0.1:5000 ngrok http 5000 instead of ngrok http 5000

Good luck

0
source

Gateway 502 error occurred because ngrok could not receive a response from Localhost.

What you need to do is: 1. Launch the web server in port 2. ngrok trigger in this port.

What I did was -> The Tomcat web server was launched in 8080 . -> Then the http 8080 popup worked.

It really works Kool .. Try it .. Hope this works for you.

0
source

I had to use both (1) the response from @ user6483104 , and (2) start my ngrok tunnel using the unprotected URL defined in my project (vs SSL URL i.e. https).

See my answer here: How to configure Visual Studio 2017 to display an unencrypted port on https ASP.Net MVC

Note. If I am mistaken that there is a raw URL by default, this answer ( How to disable Https in Visual Studio 2017 Web Proj ASP.NET Core 2.0 ) claims to have a solution to disable the secure URL. I did not try, because my existing project already had an unprotected URL (since I suspect there is one with yours)

enter image description here

-one
source

Source: https://habr.com/ru/post/1012320/


All Articles