8

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

adrienk
  • 137
  • 1
  • 2
  • 8

2 Answers2

23

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

Russ Savage
  • 548
  • 2
  • 14
1

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

if __name__ == '__main__':
    app.run(port=5002)
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
Rizwan
  • 13
  • 4