본문 바로가기

etc/it

linux killall node command use in windows taskkill /f /im node.exe Starting inspector on 127.0.0.1:9229 failed: address already in use

VScode 사용중 만나는 address already in use 에러 해결 방법

Starting inspector on 127.0.0.1:9229 failed: address already in use

killall node

리눅스에서는 이 명령어로 해결이 되지만, 윈도우 CMD에 대응하는 명령어는 taskkill이다.

이미 잘 죽지 않는 프로세스라 좀비 상태이므로 그냥 taskkill만 써선 안되고 /f 옵션을 같이 써서 강제 종료해야 한다.

C:\Work>taskkill /im node.exe

오류: 프로세스 "node.exe"(PID 1744)을(를) 종료할 수 없습니다.

원인: 이 프로세스는 /F 옵션을 사용하여 강제로 종료해야 합니다.

C:\Work>taskkill /f /im node.exe

https://stackoverflow.com/questions/14790910/stop-all-instances-of-node-js-server

Windows Machine:

Need to kill a Node.js server, and you don't have any other Node processes running, you can tell your machine to kill all processes named node.exe. That would look like this:

taskkill /im node.exe

And if the processes still persist, you can force the processes to terminate by adding the /f flag:

taskkill /f /im node.exe

If you need more fine-grained control and need to only kill a server that is running on a specific port, you can use netstat to find the process ID, then send a kill signal to it. So in your case, where the port is 8080, you could run the following:

C:\>netstat -ano | find "LISTENING" | find "8080"

The fifth column of the output is the process ID:

  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       14828
  TCP    [::]:8080              [::]:0                 LISTENING       14828

You could then kill the process with taskkill /pid 14828. If the process refuses to exit, then just add the /f (force) parameter to the command.


Linux machine:

The process is almost identical. You could either kill all Node processes running on the machine (use -$SIGNAL if SIGKILL is insufficient):

killall node

Or also using netstat, you can find the PID of a process listening on a port:

$ netstat -nlp | grep :8080
tcp        0      0 0.0.0.0:8080         0.0.0.0:*                   LISTEN      1073/node

The process ID in this case is the number before the process name in the sixth column, which you could then pass to the kill command:

$ kill 1073

If the process refuses to exit, then just use the -9 flag, which is a SIGTERM and cannot be ignored:

$ kill -9 1073

태그