flaskgoogle-colaboratoryngrok

ConnectionRefusedError: [Errno 111] Connection refused while using ngrok in google colab


Following is my code-

app = Flask(__name__, template_folder='templates')
run_with_ngrok(app)

@app.route("/")
def index():
  return render_template('index.html')

app.run()

I keep getting this error - ConnectionRefusedError: [Errno 111] Connection refused

I did get the token from ngrok account and saved it to the config. Apparently this worked for cases discussed a year ago, but for me the problem persists.


Solution

  • PM at ngrok here. Based on the code sample provided, I'm assuming you are using flask-ngrok. This flask extension is a community developed extension, not officially supported by ngrok. This extension has not been updated in 5 years and so does not work since it is pinned to a very old version of the ngrok binary, 2.3.41 (the actual link is leading to a 404). Per our version support policy, this version is not permitted to connect to ngrok.

    I would recommend using ngrok's python agent SDK since it the officially supported way to connect to ngrok with Python.