cannot quit jupyter notebook server running

Joalito picture Joalito · Jul 21, 2016 · Viewed 33.4k times · Source

I am using Jupyter Notebook for a project. Since I ssh into a linux cluster at work I use

ssh -Y -L 8000:localhost:8888 user@host

Then I start the notebook with jupyter notebook --no-browser & so that I can continue using the terminal. Then on my local machine I open to localhost:8000 and go about my work.

My problem is that I forgot several times to close the server by foregrounding the process and killing it with Ctrl-C. Instead I just logged out of the ssh session. Now when I run jupyter notebook list I get

Currently running servers:
http://localhost:8934/ :: /export/home/jbalsells
http://localhost:8870/ :: /export/home/jbalsells
http://localhost:8892/ :: /export/home/jbalsells
http://localhost:8891/ :: /export/home/jbalsells
http://localhost:8890/ :: /export/home/jbalsells
http://localhost:8889/ :: /export/home/jbalsells
http://localhost:8888/ :: /export/home/jbalsells

I obviously do not want all of these servers running on my work's machine, but I do not know how to close them!

When I run ps I get nothing:

  PID TTY          TIME CMD
12678 pts/13   00:00:00 bash
22584 pts/13   00:00:00 ps

I have Jupyter 4.1.0 installed.

Answer

Joalito picture Joalito · Jul 21, 2016

So I found a solution.

Since jupyter notebook list tells you which ports the notebook servers are running on I looked for the PIDs using netstat -tulpn I got the information from http://www.cyberciti.biz/faq/what-process-has-open-linux-port/

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       
PID/Program name    
tcp        0      0 0.0.0.0:8649            0.0.0.0:*               LISTEN      
-                   
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      
-                   
tcp        0      0 0.0.0.0:33483           0.0.0.0:*               LISTEN      
-                   
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      
39125/Xvnc          

Without looking too hard I was able to find the ports I knew to look for from jupyter notebook list and the processes running them (you could use grep if it were too hard to find them). Then I killed them with kill 8337 (or whatever number was associated).