adrienk
adrienk

Reputation: 187

Flask + ngrok - Access to subdomain.ngrok.io was denied - 403 Error

I was starting a simple Flask app and successfully hosted it locally at port 5000.

However, I couldn't set up a tunnel to a public url via ngrok.

Here are my codes:


app = Flask(__name__)

@app.route("/")
def hello_world():
    return "<p>Hello, World!!</p>"

if __name__ == '__main__':
    app.run(debug=True)

My local host is showing "Hello World!!" normally but clicking on the ngrok page shows this:

Successfully loaded ngrok

But cannot access through the subdomain url

Upvotes: 13

Views: 7550

Answers (2)

Rizwan
Rizwan

Reputation: 63

You can simply change the port by passing port argument to run:

if __name__ == '__main__':
    app.run(port=5002)

Upvotes: 6

Russ Savage
Russ Savage

Reputation: 1484

There is an issue where the latest mac os mojave uses the default port for flask. To resolve it, head over to System Preferences > Sharing and unselect the AirPlay Receiver. Or change your default flask port to something other than 5000 using flask run --port=5002 and restart your ngrok server: ngrok http 5002

Upvotes: 39

Related Questions