39
7

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 1 year has passed since last update.

Macでport:5000が使えないときの対処

Last updated at Posted at 2022-01-01

基本は以下の3つのどれかの方法で解決するはず.

エラー例

# もうすでに該当のポートは使用されている
Error response from daemon: Ports are not available: listen tcp 0.0.0.0:5000: bind: address already in use

1. kill コマンドを実行する

kill -9 $(lsof -t -i:7000)
  • lsof -tiで稼働しているポート番号を取得
  • kill -9で強制終了

2. MacのPreferenceの確認をする

  • ポートを停止しても勝手に立ち上がる
# 停止
kill -9 $(lsof -t -i:7000)
# 確認
lsof -i:7000
ControlCe 18356 username   18u  IPv4 000000000000000004      0t0  TCP *:afs3-fileserver (LISTEN)
ControlCe 18356 username   19u  IPv6 000000000000000006      0t0  TCP *:afs3-fileserver (LISTEN)
  • MacOSアップデートによる AirPlay機能 の追加によって,5000/7000ポートを占拠することがある
  • ControlCe てやつが使われているらしい.

System Preference > Sharing > AirPlay Receiver > チェックを外す

3. pkill後にすぐに接続して停止する

  • 最終手段
  • すぐ立ち上がるので立ち上がる前に接続
  • macのsharingの設定項目がない場合があるとき
  • nc -lで接続後, ctrl + cで接続を停止
pkill ControlCenter; nc -l 5000

参照

39
7
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
39
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?