67

When I am using ngrok & run url given by ngrok with following configuration:

  • my local url is : localhost:8080/someexample
  • my ngrok url is : http://f07d0862.ngrok.io/

it show this error:

Bad Request - Invalid Hostname  HTTP Error 400. 
3
  • 1
    Can you tell how are you generating the ngrok url? Commented Jun 15, 2015 at 13:52
  • 1
    Hey Sunny: can you mark the answer as correct ? Commented Jun 2, 2017 at 8:47
  • Duplicate of stackoverflow.com/questions/30535336/… Commented Nov 22, 2017 at 7:26

8 Answers 8

182

Your web server is rejecting the request since it has different hostname.

Try ngrok http -host-header="localhost:8080"

Sign up to request clarification or add additional context in comments.

5 Comments

This works perfectly, and is also a perfect solution for developing with Facebook Messenger webhooks.
This answer is missing the quotation marks around the host-header value, and the colon, should be: -host-header="localhost:8080"
Please refer the following link stackoverflow.com/questions/30535336/…
This is the command that worked for me is ngrok http -host-header=localhost 8080 Using the other command showed an error FAILED TO COMPLETE TUNNEL CONNECTION The connection to 27900a3a1d5e.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address host-header=localhost:33511. Make sure that a web service is running on host-header=localhost:33511 and that it is a valid address. The error encountered was: dial tcp: lookup host-header=localhost: no such host
I needed to use two leading dashes on ngrok 3.0.6: --host-header="localhost:8080"
41

This is the solution you want.

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

Comments

6

This worked for me:

ngrok http -host-header=localhost 8080

Comments

4

For me it was this

ngrok.exe http https://localhost:44315 --host-header=localhost:44315

1 Comment

same for me as well. Using "" didn't seem to work for me.
1

This command works for me(note the double hyphen before host keyword):

ngrok http --host-header=localhost 48333

Comments

0

If getting -o flag something error try with double -

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

Comments

0

The parameters have been updated:

ngrok http 80 --host-header="localhost:80"

EXAMPLES:
  ngrok http 80                           # secure public URL for port 80 web server
  ngrok http --domain baz.ngrok.dev 8080  # port 8080 available at baz.ngrok.dev
  ngrok http foo.dev:80                   # tunnel to host:port instead of localhost
  ngrok http https://localhost            # expose a local https server
  ngrok tcp 22                            # tunnel arbitrary TCP traffic to port 22
  ngrok tls --domain=foo.com 443          # TLS traffic for foo.com to port 443
  ngrok start foo bar baz                 # start tunnels from the configuration file

Comments

-2

May be you should turn off your firewall.

That works for me.

1 Comment

Ngrok bypasses firewall restrictions, how should a firewall be a problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.