8
6

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.

Error: listen EADDRINUSE: address already in use :::3000 の対処

Last updated at Posted at 2022-05-21

以下のエラーの対処方法について。

Error: listen EADDRINUSE: address already in use :::3000
    at Server.setupListenHandle [as _listen2] (node:net:1334:16)
    at listenInCluster (node:net:1382:12)
    at Server.listen (node:net:1469:7)

localhost:3000 のaddress が使用済みということなので該当プロセスを終了すれば良い。

該当プロセスの調査

# nodeで稼働中のプロセスを調査
ps aux | grep node

# port3000を利用してるプロセスの調査
sudo lsof -i:3000

後者のlsof -i :3000の方が確実。
sudoを付けないとほかのユーザーやrootのプロセスが見れない。

該当のプロセスIDを指定してkill

kill -9 [該当のPID]

-9 は強制終了命令(killシグナル)を送るオプション。
デフォルトのkillコマンドでは、終了命令(HUPシグナル)を送るもので、プロセスが終了しない可能性に注意。

8
6
1

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
8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?