"Unable to connect to the local runtime" in google colab

11,756

Solution 1

This issue was raised in Github issues for Collaboratory: This answer helped me https://github.com/googlecolab/jupyter_http_over_ws/issues/1#issuecomment-557469128

According to this issue

start the jupyter notebook with the below command.

jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --NotebookApp.port_retries=0 --notebook-dir="" --no-browser --allow-root --NotebookApp.token='' --NotebookApp.disable_check_xsrf=True --port=8888

then open the notebook by going to this URL.

localhost:8888

Then retry connecting to local runtime with Google Colab

If it does not solve your problem then try disabling AdBlock extension or app.

Solution 2

For Windows (10/11)

Method 1: Using git bash

follow these steps https://research.google.com/colaboratory/local-runtimes.html

Using git bash

Method 2: Using Windows terminal & Multiline commands

Install jupyter_http_over_ws

pip install jupyter_http_over_ws

enable the jupyter_http_over_ws jupyter extension (one-time)

jupyter serverextension enable --py jupyter_http_over_ws

Use multiline commands to start server and authenticate

jupyter notebook ^
  --NotebookApp.allow_origin='https://colab.research.google.com' ^
  --port=8888 ^
  --NotebookApp.port_retries=0

Using mutilines & Windows terminal

Method 3: Using single-line command & windows terminal

Install jupyter_http_over_ws

pip install jupyter_http_over_ws

enable the jupyter_http_over_ws jupyter extension (one-time)

jupyter serverextension enable --py jupyter_http_over_ws

Use single-line commands to start server and authenticate

jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=8888 --NotebookApp.port_retries=0

Using Single line and windows terminal

Once the server has started, it will print a message with the initial backend URL used for authentication. Make a copy of this URL as you'll need to provide this in the next step.

enter image description here

Connect to the local runtime In Colaboratory, click the "Connect" button and select "Connect to local runtime...". Enter the URL from the previous step in the dialog that appears and click the "Connect" button. After this, you should now be connected to your local runtime.

enter image description here

Share:
11,756
sagar francis
Author by

sagar francis

Updated on June 04, 2022

Comments

  • sagar francis
    sagar francis over 1 year

    I'm trying to connect local run time but it's not connecting,

    I used the troubleshooting dialog following commands:

    pip install jupyter_http_over_ws
    jupyter serverextension enable --py jupyter_http_over_ws
    
    jupyter notebook \ --NotebookApp.allow_origin='https://colab.research.google.com --port=8888 \--NotebookApp.port_retries=0
    

    Have tried the same above steps as said in below URL https://research.google.com/colaboratory/local-runtimes.html

    Facing an issue 'Jupyter authentication cookie was not detected' Tried by disabling adblocker, antivirus and also using different port numbers. Below was the solution given by team

    Navigate to http://localhost:8888 in a separate browser tab and follow the provided instructions. This will set a browser cookie used for authentication between the browser and the Jupyter notebook server.

    But when I open the URL, it asks for a password(already set up) and then no further instructions are appearing.

    • vincrichaud
      vincrichaud over 4 years
      Do you get an error ?
    • sagar francis
      sagar francis over 4 years
      I didn't get an error but I'm not able to connect local runtime
  • sagar francis
    sagar francis over 4 years
    I have used Troubleshoot commands only but still I'm not able to connect
  • Bob Smith
    Bob Smith over 4 years
    More information will be helpful to diagnose. For example: What adjustments were recommended by the troubleshoot command? How did you change your invocation? What error are you observing? Is your Jupyter backend running locally, or are you attempting to connect remotely via an SSH tunnel?
  • sagar francis
    sagar francis over 4 years
    When I run Troubleshoot command Jupyter browser is opening but Colab is not connecting to local runtime again its showing Troubleshooting dialog
  • Kris
    Kris over 2 years
    This may allow you to connect, but it basically disables all security features.
  • Mare Seestern
    Mare Seestern over 1 year
    In my case, it was port sensitive. I needed to kill another process which was running on port 8888.