How to do port forwarding to local host


#1

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?


#2

Use the flag after the ssh command

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


#3

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

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


#4

Yes.

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


#5

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:
runit
git-daemon-run
E: Sub-process /usr/bin/dpkg returned an error code (1)


#6

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


#7

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.


#8

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/jupyter_notebook_config.py
echo "c.NotebookApp.open_browser = False" >> ~/.jupyter/jupyter_notebook_config.py```

#9

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://35.194.201.131:8888/api/kernels/66719ae6-6324-4cf3-b848-3aaca324fc20/channels?session_id=B0057ED91BF84CBBA9CDEB463419205A’ 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?


#10

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.