title: Connect Google colab to a runtime on a Google Compute Engine instance
body: <p>I am trying to connect a jupyter notebook on Google colab to a runtime on GCP EC2 instance. I followed this colab doc instructions <a href="https://research.google.com/colaboratory/local-runtimes.html" rel="nofollow noreferrer">Link</a></p>
  <p>Steps taken:</p>
  <ul>
  <li><p>Set up a Jupyter server on my local</p>
  <pre><code>pip install jupyter_http_over_ws &amp;&amp; jupyter serverextension enable --py jupyter_http_over_ws
  
  jupyter notebook \
   --NotebookApp.allow_origin='https://colab.research.google.com' \
   --port=8888 \
   --NotebookApp.port_retries=0
  </code></pre>
  </li>
  <li><p>Create and start a EC2 instance on GCP</p>
  </li>
  <li><p>SSH into EC2 instance and forward local port using:</p>
  <pre><code>gcloud beta compute ssh --zone &quot;europe-west2-c&quot; &quot;&lt;ec2-instance-name&gt;&quot; --project &quot;&lt;project-name&gt;&quot; -- -L 8888:localhost:8888
  </code></pre>
  </li>
  </ul>
  <p>Error Message from trying to forward the port:</p>
  <pre><code>bind [127.0.0.1]:8888: Address already in use
  channel_setup_fwd_listener_tcpip: cannot listen to port: 8888
  Could not request local forwarding.
  </code></pre>
  <p>I also tried connecting the ec2 instance directly to colab but I was unable to. For the final step, I am suppose to copy the Jupyter url to the colab local runtime. How can I fix this?</p>