Two jupyter notebook running at the same port

Viewed 3421

I am using the Ubuntu sub-system on Windows 10.

I opened a terminal and entered the command:

jupyter notebook 

and then a notebook is started at port 8888. Without closing this one, I opened another terminal and typed in jupyter notebook again, the new terminal says that:

[I 15:09:00.576 NotebookApp] The Jupyter Notebook is running at:
[I 15:09:00.577 NotebookApp] http://localhost:8888/?token=

with a different token number from the notebook running in the first terminal. If I open localhost:8888 with my browser and enter the token from the second terminal, jupyter rejects me, while the token from the first terminal passes.

I was wondering why can there be two notebooks running on the same 8888 port? If I kill the notebook in the second terminal, will it affect the notebook running in the first terminal?

1 Answers

Short answer - you can't have 2 notebooks server running on the same port.

From Jupyter documentation:

You can start more than one notebook server at the same time, if you want to work on notebooks in different directories. By default the first notebook server starts on port 8888, and later notebook servers search for ports near that one. You can also manually specify the port with the --port option.

This is probably a networking issue or caused by your environment configuration. Basically, For TCP/IP you can only have one application listening on the same port at one time. Now if you had 2 network cards, you could have one application listen on the first IP and the second one on the second IP using the same port number. For UDP (Multicasts), multiple applications can subscribe to the same port.

You can always run the second server with --port option and port of your choosing.

Related