2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

tmux上でjupyter notebookを起動したら"in use"なポートが増えまくった

Last updated at Posted at 2018-06-19

#困ったこと
サーバー上のjupyter notebookにローカルからアクセスするときに,

[I 19:07:16.085 NotebookApp] The port 6060 is already in use, trying another port.
[I 19:07:16.086 NotebookApp] The port 6061 is already in use, trying another port.
[I 19:07:16.086 NotebookApp] The port 6062 is already in use, trying another port.
[I 19:07:16.086 NotebookApp] The port 6063 is already in use, trying another port.
[I 19:07:16.093 NotebookApp] http://[all ip addresses on your system]:6064/

こんなのが表示されるようになった.
ポートの6060~6063が埋まってるので6064を割り当てたよということらしい.
ちなみにデフォルトポートは6060に設定してある.
このままだと無限に"in use"なポートが増えそうで怖かったので,状況を調べた.

#原因
tmux上のjupyter notebookへのアクセス中にsshが切れると,ポートを占有しているプロセスが生き残るらしい.おそらくこれが原因.

#解決法
netstat -tanpでポートを使用しているプロセスIDを調べて,killすればOK.

$ netstat -tanp
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp6       0      0 :::6060                 :::*                    LISTEN      36328/python    
tcp6       0      0 :::6061                 :::*                    LISTEN      36503/python    
tcp6       0      0 :::6062                 :::*                    LISTEN      38354/python    
tcp6       0      0 :::6063                 :::*                    LISTEN      40751/python

pythonのプロセスがポートを使用していた.

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?