google-colaboratoryngrokpyngrok

How to configure ngrok with google colab


I am using pyngrok in google colab and getting following error

The ngrok process errored on start: Your ngrok-agent version "2.3.41" is too old. The minimum supported agent version for your account is "3.2.0". Please update to a newer version with ngrok update, by downloading from https://ngrok.com/download, or by updating your SDK version. Paid accounts are currently excluded from minimum agent version requirements. To begin handling traffic immediately without updating your agent, upgrade to a paid plan: https://dashboard.ngrok.com/billing/subscription.\r\n\r\nERR_NGROK_121\r\n.

!pip install pyngrok
from pyngrok import ngrok

http_tunnel = ngrok.connect()

To resolve this I manually upgrade ngrok using terminal to 3.8 (following https://ngrok.com/download) but I still get this error. Is it ngrok which pyngrok use is of old version. I'm am little confused after trying so many combination to work to set up ngrok with google colab.

Things I tried

It just don't setup the connection.My python version 3.10

Any clue what I might be missing.


Solution

  • pyngrok already manages its own binary, so when you're downloading the update yourself, you're not actually updating the ngrok binary that pyngrok will use by default.

    You have a couple options:

    1. Run update command through pyngrok, per the docs, so that it downloads and updates the binary that it will use.
    from pyngrok import ngrok
    
    ngrok.update()
    
    1. Alternatively, you can override pyngrok's default behavior of using its own binary and set ngrok_path to point to the one you've downloaded, per the docs.
    from pyngrok import conf, ngrok
    
    conf.get_default().ngrok_path = "/usr/local/bin/ngrok"
    
    # <NgrokTunnel: "https://<public_sub>.ngrok.io" -> "http://localhost:80">
    ngrok_tunnel = ngrok.connect()
    
    1. Have you seen that the pyngrok docs include an example for Google Colab, including a Notebook that you could save as your own? Maybe start from there and work your way back to your script to identify where it's going wrong