How to do port forwarding to local host


When I open up my kernel in Jupyter Notebook through GCP, the kernel isn’t connected. How do I port forward to local host to avoid that error?


Use the flag after the ssh command

ssh [email protected] -L 8888:localhost:8888


The Ip required should be the external IP on GCP right?

When I tried, I encountered this error:
ssh: connect to host port 22: Connection refused



Did you allow access via ssh (SSH uses port 22).


How to allow access via ssh?

I follow this post to install openssh-server but encounter following error:

Processing triggers for systemd (229-4ubuntu21) …
Processing triggers for ureadahead (0.100.0-19) …
Processing triggers for ufw (0.35-0ubuntu2) …
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)


Could you share the script you used to setup the GCP instance?


Recommendation Recommendation

I followed this example shared in slack group.

I have no issue connecting the Jupyter kernel at home, but having connection problem for the kernel in workplace. Asked Jiaqing on Ai-saturdays section and he helped me to post this port forwarding question.


try checking the firewall rules - I find that a lot of people are having issues connecting to Jupyter using @howkhang 's guide.

What I did to fix it was just get rid of my old firewall rules, made a new rule on the google cloud console and redid my Jupyter configs with:

jupyter notebook --generate-config
echo "c.NotebookApp.ip = '*'" >> ~/.jupyter/
echo "c.NotebookApp.open_browser = False" >> ~/.jupyter/```


Thanks for the suggestion! Tried the code but doesn’t solve the kernel connection problem in the workplace ><

Found that it is showing websocket connection error:
WebSocket connection to ‘ws://’ failed: Error during WebSocket handshake: Unexpected response code: 500

Any method to verify if it is due to company proxy issue or blocked by antivirus?


My random way of verifying that is, checking if I can access it from a Cafe’ wifi. If It can be accessed, there’s something wrong with the company firewall.