๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Lect & Tip/vscode

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 ์—๋Ÿฌ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•

by ๋‚ฏ์„ ๊ณต๊ฐ„2019 2023. 8. 29.

๋ชฉ์ฐจ

    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

    Windows ํ™˜๊ฒฝ์—์„œ VSCode ์‚ฌ์šฉ ์‹œ ๋ฐœ์ƒํ•˜๋Š” "address already in use" ์—๋Ÿฌ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

    ์˜ค๋Š˜์€ Windows ํ™˜๊ฒฝ์—์„œ VSCode๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด์„œ ์ž์ฃผ ๋งˆ์ฃผ์น˜๊ฒŒ ๋˜๋Š” "address already in use" ์—๋Ÿฌ์— ๋Œ€ํ•œ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์„ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์ด ์˜ค๋ฅ˜๋Š” ์ข…์ข… 127.0.0.1:9229์™€ ๊ฐ™์€ ์ฃผ์†Œ์—์„œ ๋ฐœ์ƒํ•˜๋Š”๋ฐ, ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ๋ช‡ ๊ฐ€์ง€ ๋‹จ๊ณ„๋ฅผ ๋”ฐ๋ผ๊ฐ€๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

    ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•: taskkill ๋ช…๋ น์–ด ์‚ฌ์šฉ

    ์œ ๋‹‰์Šค ๊ณ„์—ด ์‹œ์Šคํ…œ์—์„œ๋Š” killall node ๋ช…๋ น์–ด๋กœ ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ Windows ํ™˜๊ฒฝ์—์„œ๋Š” ํ•ด๋‹น ๋ช…๋ น์–ด ๋Œ€์‹  taskkill ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค๋งŒ ๊ฐ„๋‹จํžˆ taskkill ๋ช…๋ น์–ด๋งŒ ์‚ฌ์šฉํ•ด์„œ๋Š” ์›ํ™œํ•œ ์ข…๋ฃŒ๊ฐ€ ์ด๋ค„์ง€์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ /f ์˜ต์…˜์„ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ•์ œ ์ข…๋ฃŒํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

    ๋‹จ๊ณ„ 1: Taskkill ๋ช…๋ น์–ด ์‚ฌ์šฉ

    taskkill /im node.exe

    ๋งŒ์•ฝ ํ”„๋กœ์„ธ์Šค๊ฐ€ ์—ฌ์ „ํžˆ ์ข…๋ฃŒ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด, /f ์˜ต์…˜์„ ์ถ”๊ฐ€ํ•˜์—ฌ ๊ฐ•์ œ ์ข…๋ฃŒํ•ฉ๋‹ˆ๋‹ค.

    ๋‹จ๊ณ„ 2: ๊ฐ•์ œ ์ข…๋ฃŒ

    taskkill /f /im node.exe

    Stack Overflow์—์„œ ์ฐพ์€ ์œ ์šฉํ•œ ์ •๋ณด

    ์œ ์šฉํ•œ Stack Overflow ๊ธ€์—์„œ ๋ฐœ๊ฒฌํ•œ ์ •๋ณด๋ฅผ ๊ณต์œ ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

    "address already in use" ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ ๊ฒฝ์šฐ, ์ปดํ“จํ„ฐ์— ๋‹ค๋ฅธ Node ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‹คํ–‰ ์ค‘์ด์ง€ ์•Š์€ ๊ฒฝ์šฐ์—๋Š” taskkill /im node.exe ๋ช…๋ น์–ด๋กœ ๋ชจ๋“  node.exe ํ”„๋กœ์„ธ์Šค๋ฅผ ์ข…๋ฃŒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿผ์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  ํ”„๋กœ์„ธ์Šค๊ฐ€ ๊ณ„์†ํ•ด์„œ ๋‚จ์•„์žˆ๋Š” ๊ฒฝ์šฐ, /f ํ”Œ๋ž˜๊ทธ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ํ”„๋กœ์„ธ์Šค๋ฅผ ๊ฐ•์ œ ์ข…๋ฃŒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ํฌํŠธ ๊ธฐ๋ฐ˜์œผ๋กœ ํ”„๋กœ์„ธ์Šค ์ข…๋ฃŒํ•˜๊ธฐ

    ํŠน์ • ํฌํŠธ์—์„œ ์‹คํ–‰ ์ค‘์ธ ์„œ๋ฒ„๋งŒ ์ข…๋ฃŒํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, ํฌํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ํ”„๋กœ์„ธ์Šค์˜ ID๋ฅผ ์•Œ์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด netstat ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ•ด๋‹น ํฌํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ํ”„๋กœ์„ธ์Šค์˜ ID๋ฅผ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ๋‹จ๊ณ„ 1: ํ”„๋กœ์„ธ์Šค ID ์ฐพ๊ธฐ

    netstat -ano | find "LISTENING" | find "8080"

    ์œ„ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ์ถœ๋ ฅ ์ค‘ ๋‹ค์„ฏ ๋ฒˆ์งธ ์—ด์— ํ”„๋กœ์„ธ์Šค ID๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ์ด ID๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ข…๋ฃŒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ๋‹จ๊ณ„ 2: ํ”„๋กœ์„ธ์Šค ๊ฐ•์ œ ์ข…๋ฃŒ

    taskkill /f /pid ํ”„๋กœ์„ธ์Šค_ID

    ๋งŒ์•ฝ ํ”„๋กœ์„ธ์Šค๊ฐ€ ์—ฌ์ „ํžˆ ์ข…๋ฃŒ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด, -9 ํ”Œ๋ž˜๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ•์ œ๋กœ ์ข…๋ฃŒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    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

     

    ๊ฒฐ๋ก 

    Windows ํ™˜๊ฒฝ์—์„œ VSCode๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด์„œ "address already in use" ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๋ฉด, taskkill ๋ช…๋ น์–ด์™€ ๊ทธ ์˜ต์…˜๋“ค์„ ์ ์ ˆํžˆ ์‚ฌ์šฉํ•˜์—ฌ ์˜ค๋ฅ˜๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์œ„์—์„œ ์†Œ๊ฐœํ•œ ๋ฐฉ๋ฒ•์„ ๋”ฐ๋ผ ํ•˜๋‚˜์”ฉ ์‹œ๋„ํ•ด๋ณด์„ธ์š”. ๊ทธ๋ฆฌ๊ณ  ํ•ญ์ƒ ๊ฐ•์ œ ์ข…๋ฃŒ๋ฅผ ์‹œ๋„ํ•˜๊ธฐ ์ „์— ๋‹ค๋ฅธ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•๋“ค์„ ๋จผ์ € ๊ณ ๋ คํ•ด๋ณด๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

    ๊ด€๋ จ ๋งํฌ

     

    stop all instances of node.js server

    This is my first time working with Node.js and I ran into this problem: I have started a Node server through the plugin of an IDE. Unfortunately, I cannot use the IDE's terminal. So I tried to run...

    stackoverflow.com

    ๊ด€๋ จ ํ‚ค์›Œ๋“œ

    Node.js, VSCode, address already in use, taskkill, ํ”„๋กœ์„ธ์Šค ์ข…๋ฃŒ, ํฌํŠธ ๊ด€๋ฆฌ


    ์ฐธ๊ณ : ์œ„์˜ ๋‚ด์šฉ์€ Windows ํ™˜๊ฒฝ์—์„œ "address already in use" ์˜ค๋ฅ˜๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ฃผ์˜๊นŠ๊ฒŒ ์ฝ์–ด๋ณด์‹œ๊ณ  ์ ์ ˆํ•œ ๋ฐฉ๋ฒ•์„ ์„ ํƒํ•ด ์˜ค๋ฅ˜๋ฅผ ํ•ด๊ฒฐํ•˜์‹œ๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.

    ๋ฐ˜์‘ํ˜•

    ๋Œ“๊ธ€