Bad Request - Invalid Hostname HTTP Error 400. The request hostname is invalid. when i am using ngrok
Asked Answered
G

7

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. 
Godgiven answered 3/6, 2015 at 11:9 Comment(3)
Can you tell how are you generating the ngrok url?Aaronson
Hey Sunny: can you mark the answer as correct ?Poignant
Duplicate of #30535836Preferable
F
182

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

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

Firkin answered 9/12, 2015 at 15:37 Comment(5)
This works perfectly, and is also a perfect solution for developing with Facebook Messenger webhooks.Alben
This answer is missing the quotation marks around the host-header value, and the colon, should be: -host-header="localhost:8080"Aquatint
Please refer the following link #30535836Preferable
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 hostCloudy
I needed to use two leading dashes on ngrok 3.0.6: --host-header="localhost:8080"Wavellite
S
40

This is the solution you want.

ngrok http 8080 -host-header="localhost:8080"
Selfpossessed answered 3/6, 2015 at 11:9 Comment(0)
J
6

This worked for me:

ngrok http -host-header=localhost 8080
Jotting answered 19/1, 2021 at 16:22 Comment(0)
C
3

For me it was this

ngrok.exe http https://localhost:44315 --host-header=localhost:44315
Cobnut answered 2/6, 2022 at 6:21 Comment(0)
L
1

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

ngrok http --host-header=localhost 48333
Letti answered 6/1, 2024 at 11:9 Comment(0)
A
0

If getting -o flag something error try with double -

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

Adrienadriena answered 26/10, 2022 at 20:27 Comment(0)
R
-2

May be you should turn off your firewall.

That works for me.

Rollick answered 26/3, 2018 at 5:15 Comment(1)
Ngrok bypasses firewall restrictions, how should a firewall be a problem.Joggle

© 2022 - 2025 — McMap. All rights reserved.