How to log back in using SSH after logging out? - python

I logged out of my jupyter notebook which I had set up on my google cloud using SSH. Now, it needs password to log me in again.
To log back in (and get a password), I use the following code in the SSH window:
jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser &
and I get this message:
I 18:06:11.509 NotebookApp] The port 8888 is already in use, trying another port.
[I 18:06:11.509 NotebookApp] The port 8889 is already in use, trying another port.
[I 18:06:11.509 NotebookApp] The port 8890 is already in use, trying another port.
[I 18:06:11.510 NotebookApp] The port 8891 is already in use, trying another port.
[I 18:06:11.510 NotebookApp] The port 8892 is already in use, trying another port.
[I 18:06:14.111 NotebookApp] jupyter_tensorboard extension loaded.
[I 18:06:14.188 NotebookApp] JupyterLab extension loaded from /usr/local/lib/python3.5/dist-packages/jupyterlab
[I 18:06:14.189 NotebookApp] JupyterLab application directory is /usr/local/share/jupyter/lab
[I 18:06:14.269 NotebookApp] Serving notebooks from local directory: /home/m_saljooghian
[I 18:06:14.269 NotebookApp] The Jupyter Notebook is running at:
[I 18:06:14.269 NotebookApp] http://(strongestf or 127.0.0.1):8827/?token=b996457bf3ce30f4da4d1f78f32e8592aa500bceef1b42e7
[I 18:06:14.269 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 18:06:14.273 NotebookApp]
To access the notebook, open this file in a browser:
file:///home/m_saljooghian/.local/share/jupyter/runtime/nbserver-3875-open.html
Or copy and paste one of these URLs:
http://(strongestf or 127.0.0.1):8827/?token=b996457bf3ce30f4da4d1f78f32e8592aa500bceef1b42e7
My initial port is 8888, but when I use the token for port 8888, it says "invalid credentials." when I try port 8827 (which is assigned by the SSH), the web page doesn't open. It says "This site can’t be reached."
I know my question is messy, but I did not know what else I should include. I appreciate your solutions or even suggestions to improve this question.

You have opened only the port 8888 in your GCP network settings so you will get connection refused on any other port. Try to kill your existing jupyter processes and free up port 8888 and try again

Related

Docker - Connecting to Jupyter notebook

I am trying to run Jupyter notebook in docker for that I tried the command -
docker run -p 8888:8888 jupyter/scipy-notebook
Executing the command: jupyter notebook
[I 04:19:53.460 NotebookApp] Writing notebook server cookie secret to /home/jovyan/.local/share/jupyter/runtime/notebook_cookie_secret
[I 04:19:53.856 NotebookApp] JupyterLab extension loaded from /opt/conda/lib/python3.8/site-packages/jupyterlab
[I 04:19:53.856 NotebookApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
[I 04:19:53.859 NotebookApp] Serving notebooks from local directory: /home/jovyan
[I 04:19:53.859 NotebookApp] Jupyter Notebook 6.1.4 is running at:
[I 04:19:53.859 NotebookApp] http://ed93c6a6ff91:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c
[I 04:19:53.859 NotebookApp] or http://127.0.0.1:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c
[I 04:19:53.859 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 04:19:53.861 NotebookApp]
To access the notebook, open this file in a browser:
file:///home/jovyan/.local/share/jupyter/runtime/nbserver-6-open.html
Or copy and paste one of these URLs:
http://ed93c6a6ff91:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c
or http://127.0.0.1:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c
When I try to connect to the notebook (I tried three different browsers) using the following urls -
file:///home/jovyan/.local/share/jupyter/runtime/nbserver-6-open.html
OR
http://ed93c6a6ff91:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c
I get the error the site cannot be reached instantly with error code ERR_NAME_NOT_RESOLVED, while using the url -
http://127.0.0.1:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c
the browser would keep trying to connect for a while and then get ERR_CONNECTION_RESET
I tried to disable my VPN. I also tried setting the no_proxy variable using export no_proxy=127.0.0.1 but I was still not able to connect to the jupyter notebook.
OS - Manjaro Linux,
docker image -
REPOSITORY TAG IMAGE ID CREATED SIZE
jupyter/scipy-notebook latest b8f7562c1262 4 days ago 2.7GB
Any help or guidance on how I can troubleshoot and connect to the notebook would be much helpful.
Or copy and paste one of these URLs:
http://ed93c6a6ff91:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c
or http://127.0.0.1:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c
↑ That is your docker container IP and hostname. You need to connect using IP outside of docker container.
For example if your docker host (physical linux machine) IP is 192.168.0.100 try to access
http://192.168.0.100:8888/?token=40c97f5c727829f0c094449618af1cad30d56a8d5c252b6c
If you can't access in this case, try to set your host IP by running
docker run -p 192.168.0.100:8888:8888 jupyter/scipy-notebook
Edit 1. How to check opened ports.
Try to run
sudo netstat -ntpl | grep 8888
If you will see something like
tcp6 0 0 :::8888 :::* LISTEN 1234/docker-proxy
Or
tcp 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN 1234/docker-proxy
That means that your docker running fine and forwarding 8888 port to all local IPs (localhost including).
So if you can see open port but can't connect, firewall will be most likely cause.

Google Colab local runtime connecting error

I want to connect Google Colab to my local jupyter runtime. I installed the below extension as suggested by colab.
pip install --upgrade jupyter_http_over_ws>=0.0.7 && jupyter serverextension enable --py jupyter_http_over_ws
Then I run the command and started a jupyter notebook. After that I try to connect google colab to the local runtime with the prompted URL. But then I got the follow issue. Please help me to solve this.
F:\Education\SEMESTER 7\CO421 FINAL YEAR PROJECT\PROJECT\josh>jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com'--port=8888 --NotebookApp.port_retries=0
jupyter_http_over_ws extension initialized. Listening on /http_over_websocket
[I 12:01:45.043 NotebookApp] Serving notebooks from local directory: F:\Education\SEMESTER 7\CO421 FINAL YEAR PROJECT\PROJECT\josh
[I 12:01:45.043 NotebookApp] Jupyter Notebook 6.1.4 is running at:
[I 12:01:45.043 NotebookApp] http://localhost:8888/?token=9308f0fdb2a8ebe003eec56aa2684dfb7c51c873ba0d9214
[I 12:01:45.043 NotebookApp] or http://127.0.0.1:8888/?token=9308f0fdb2a8ebe003eec56aa2684dfb7c51c873ba0d9214
[I 12:01:45.043 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 12:01:45.125 NotebookApp]
To access the notebook, open this file in a browser:
file:///C:/Users/prasa/AppData/Roaming/jupyter/runtime/nbserver-6268-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=9308f0fdb2a8ebe003eec56aa2684dfb7c51c873ba0d9214
or http://127.0.0.1:8888/?token=9308f0fdb2a8ebe003eec56aa2684dfb7c51c873ba0d9214
[W 12:02:15.646 NotebookApp] Blocking Cross Origin API request for /http_over_websocket. Origin: https://colab.research.google.com, Host: localhost:8888
[W 12:02:15.647 NotebookApp] 403 GET /http_over_websocket?min_version=0.0.7&jupyter_http_over_ws_auth_url=http%3A%2F%2Flocalhost%3A8888%2F%3Ftoken%3D5d6bb0b08b718df4fMUpVa4LvtUpaHGkcUqPkMpyiaoG8817 (::1) 2.99ms referer=None

Can not open jupyter notebook in localhost in ubuntu

I didn't run jupyter notebook for a long time, Today when I try to launch to notebook , I can't run it and I encountered this:
[I 19:05:29.939 NotebookApp] 0 active kernels
[I 19:05:29.939 NotebookApp] The Jupyter Notebook is running at:
[I 19:05:29.939 NotebookApp] http://localhost:9999/
[I 19:05:29.939 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Opening in existing browser session.
Then can not open in browser. I looked up other similar question but I didn't find to solution.

Jupyter Notebook is not being opened in windows using Anaconda Prompt?

1) I tried to open Jupyter Notebook in Anaconda prompt.
Ananconda Prompt:
(C:\Users\sankarreddy\Anaconda3) C:\Users\sankarreddy>jupyter notebook
[I 21:24:52.854 NotebookApp] Serving notebooks from local directory: C:\Users\sankarreddy
[I 21:24:52.855 NotebookApp] 0 active kernels
[I 21:24:52.856 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=fb39c20421e31cc66fddfd4fc00c7f64b8003bc53b83f461
[I 21:24:52.856 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 21:24:52.868 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=fb39c20421e31cc66fddfd4fc00c7f64b8003bc53b83f461
2) My default browser is Google chrome and every time when I try to open the Jupyter notebook, the following is the result.
Result in the Browser(Google Chrome):
ERROR: Gateway Timeout
While trying to retrieve the URL http://localhost:8888/tree?token=4f3786890eceb91493af9bd6f4b07ae1ac6888c6172bbfca:
Connection refused
Your cache administrator is webmaster.
Generated Sun, 23 Jul 2017 14:01:21 GMT by 103.217.212.129 (Mikrotik HttpProxy)
3) I interrupted the process using 'Ctrl+C'.. it displays as follows.
[I 19:43:23.364 NotebookApp] Interrupted...
[I 19:43:23.365 NotebookApp] Shutting down kernels
I have googled about this issue, but had very little help which is of no use.
It seems like you're trying to open Jupyter Notebook in port 8888 as stated by the error message While trying to retrieve the URL http://localhost:8888/tree?token=4f3786890eceb91493af9bd6f4b07ae1ac6888c6172bbfca
But, when running Jupyter Notebook, there was an error message stating something else is running in port 8888 and it started the server in the next available port, which is 8889: [I 19:26:39.239 NotebookApp] The Jupyter Notebook is running at: http://localhos t:8889/?token=86664b50ba28f3bd3431554bc84d60d8bf4f3bf4209a4ecf
I'm not sure how to identify what is running on 8888, but you should definitely access your Jupyter Notebook on localhost:8889 .

How to use docker to connect with jupyter notebooks

I try to connect to jupyter notebooks from macos terminal, but when I use
python run_docker_jupyter.py
it returns me
Projects/data_science_course/mlcourse_open:/notebooks -w /notebooks festline/mlcourse_open jupyter
Command: jupyter
[I 14:12:55.078 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 14:12:55.101 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[W 14:12:55.101 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using authentication. This is highly insecure and not recommended.
[I 14:12:55.113 NotebookApp] Serving notebooks from local directory: /notebooks
[I 14:12:55.114 NotebookApp] 0 active kernels
[I 14:12:55.114 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:4545/
[I 14:12:55.114 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
And I need to connect with local host, but after some command it returns me nothing. Or if I use docker ps or another docker command, it only prints this command in the terminal with sign [ before the command and after that it turn to next string. And that's all.
It's the first time I use docker, so I will be grateful for the help.
Try to use test your python first, e.t. try to run something as simple as:
python -c "print('test')"
you should have you "test" string as output.
Then try to check your docker:
issue:
$docker-machine ssh
if everything is okay you will be able to run
$docker ls
There is a known issue with kernel crashes that can be fixed by using Tini, I have attached links to a couple of gists that work very well.
Docker-compose yaml and Dockerfile

Categories