Ricky
Ricky

Reputation: 705

Index out of error in while deploying flask app using ngrok

I have created a server using Flask for a demonstration of my ML model. I was running it on Google Colab and using flask-ngrok for tunneling. It was working properly, but suddenly it stopped working today and is showing this error:

=> loading checkpoint './semi_supervised_model_3/ckpt_epoch_10.00.pth'
=> loaded checkpoint './semi_supervised_model_3/ckpt_epoch_10.00.pth' (epoch 10.0)
 * Serving Flask app "demo_Server" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 1182, in run
    self.function(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/dist-packages/flask_ngrok.py", line 70, in start_ngrok
    ngrok_address = _run_ngrok()
  File "/usr/local/lib/python3.6/dist-packages/flask_ngrok.py", line 38, in _run_ngrok
    tunnel_url = j['tunnels'][0]['public_url']  # Do the parsing of the get
IndexError: list index out of range

What is the meaning of this error? Why is it coming even when I didn't change anything?

Upvotes: 1

Views: 1381

Answers (2)

Thanujan
Thanujan

Reputation: 1

which because that of the small delay, the program is unable to retrieve the public URL in the subsequent lines of code.when you have the internet connection is not fast enough, this small delay might not be enough.

Try to increase time.sleep in _run_ngrok() method in the flask_ngrok.py file which is included in python3.6/site-packages when you install it.

Upvotes: 0

Ricky
Ricky

Reputation: 705

My problem got solved when I terminated the current session. In the new session, I reinstalled flask-ngrok and it worked fine.

Upvotes: 1

Related Questions