3

My IDE is Pycharm. I want to test my app locally, so I run my service locally and use ngrok to expose my app to Internet.

The url showed by ngrok is https://436cb7e9.ngrok.io

But when I want to verify the facebook webhook callback url use this url above, it shows

ERROR 2017-12-27 08:16:37,407 wsgi_server.py:329] Request Host 436cb7e9.ngrok.io not whitelisted. Enabled hosts are set(['localhost'])

I ran the app well before, but I don't know why this time it shows an error. Could somebody gives me suggestion?

Brady Huang
  • 1,852
  • 20
  • 23
  • You need to put your `436cb7e9.ngrok.io` to list of allowed hosts. Don't know what framework you use. But read error description carefully. – vishes_shell Dec 27 '17 at 08:41
  • 1
    @vishes_shell Thanks for your reply. But I don't know how to set the url as allowed hosts. The framework I use is Flask. Actually, after spending all day, I find out that is the problem I upgrade my gcloud from 182.0.0 to 183.0.0, then my host is blocked. So I downgrade to 182.0.0 eventually. – Brady Huang Dec 28 '17 at 02:15

4 Answers4

6

After a bit of digging and thanks to Brady's comment about the gcloud version, I found out that all you need to fix this is to add a flag when you run your app.

So, say you run your app locally with:

python $APPENGINE/dev_appserver.py

just change it to:

python $APPENGINE/dev_appserver.py --enable_host_checking=false

and you should not have the host whitelist errors anymore.

For more information, checkout the release notes here: https://cloud.google.com/appengine/docs/standard/python/release-notes#december_5_2017

This seems to be working fine for me on gcloud 183.0.0 and 187.0.0 (the latest version at the time of writing of this comment).

Arnaud Valle
  • 1,673
  • 1
  • 16
  • 25
  • a better workaround in my opinion is to keep the default for the enable_host_checking (that is true) and use ngrok that way ```./ngrok http 8080 -subdomain=yourallowedsubdomain -host-header=localhost:8080``` . You just have to register yourallowedsubdomain in your project and the taskqueue won't complain about the host header anymore – euri10 Mar 27 '18 at 09:29
0

It is done via the Auth tab of your ngrok dashboard. From IP Whitelisting Tunnel Access:

You may whitelist access to tunnel endpoints on your account. The whitelist is enforced by the ngrok.com servers. It is applied globally to all of your tunnel endpoints. Any incoming connection to any of your tunnel endpoints is checked to guarantee that the source IP address of the connection matches at least one entry in your whitelist. If a connection does not match the whitelist it is terminated immediately and never forwarded to an ngrok client.

As a special case, if your whitelist is empty, all connections are allowed.

Managing the whitelist

You can manage the IP whitelist on the auth tab of your ngrok dashboard. Enter a new IP address under the "IP Whitelist" section and then click Add Whitelist Entry. Changes to the IP Whitelist can take up to 30 seconds to take effect.

IP Ranges

Sometimes, you may wish to whitelist an entire range of IPs. Instead of entering just a single IP address, you may instead specify a block of IP addresses using CIDR notation. For example, to allow all IP addresses from 10.1.2.0 to 10.1.2.255, you would add 10.1.2.0/24 to your whitelist.

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • This is no longer correct as there is no Auth tab and the docs link no longer points to how to do it. Any idea how this is done in 2022? – warmwhisky Oct 18 '22 at 06:41
0

I had a slightly different question, but google lead me here none the less, the error I had was:

"The callback URL or verify token couldn't be validated. Please verify the provided information or try again later."

When trying to connect facebooks webhook to my localhost. Turns out I needed to authenticate my ngrok agent: https://dashboard.ngrok.com/get-started/your-authtoken

0

switch your ngrok server location and it works ngrok http 3000 --region ap work for me also.

ngrok http -region us 80 (US is not working) ngrok http -region eu 80 ngrok http -region ap 80 ngrok http -region au 80

Nidhish
  • 91
  • 4