Home Node.js address already in use
Post
Cancel

Node.js address already in use

๐Ÿ’ก Port ๋ฒˆํ˜ธ๊ฐ€ ์ด๋ฏธ ์‚ฌ์šฉ๋˜๊ณ  ์žˆ์œผ๋ฏ€๋กœ ๋‹ค๋ฅธ port ๋ฒˆํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜๋ผ๋Š” ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค.

์—๋Ÿฌ

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
server.js
events.js:352
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::8080
    at Server.setupListenHandle [as _listen2] (net.js:1320:16)
    at listenInCluster (net.js:1368:12)
    at Server.listen (net.js:1454:7)
    at Function.listen (/Users/lyk/Documents/GitHub/Support/node_modules/express/lib/application.js:618:24)
    at Object.<anonymous> (/Users/lyk/Documents/GitHub/Support/server.js:13:5)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1347:8)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  code: 'EADDRINUSE',
  errno: -48,
  syscall: 'listen',
  address: '::',
  port: 8080
}

์œ„์™€ ๊ฐ™์ด 8080์„ ์“ฐ๋ ค๋Š” ์ˆœ๊ฐ„ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค. ์ด ์ „์— 8080 port๋ฅผ ์‚ฌ์šฉํ•˜๋‹ค๊ฐ€ ๋น„์ •์ƒ์ ์œผ๋กœ ์ข…๋ฃŒ์‹œํ‚จ๊ฑฐ ๊ฐ™๋‹ค.

ํ•ด๊ฒฐ

  • 8080 port๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” ํ”„๋กœ์„ธ์Šค์˜ id๋ฅผ ์•Œ์•„๋‚ด์•ผ ํ•œ๋‹ค.
  • sudo lsof -i :8080 ๋ฅผ ํ†ตํ•ด ์•Œ ์ˆ˜ ์žˆ๋‹ค.
  • ์ด์ œ ์ด ํ”„๋กœ์„ธ์Šค๋ฅผ ์ฃฝ์ธ๋‹ค.
  • sudo kill -9 [pid]
  • lsof์— ๊ด€ํ•˜์—ฌ
    • lsof๋Š” list open files์˜ ์•ฝ์ž๋กœ ์‹œ์Šคํ…œ์— ์—ด๋ ค์žˆ๋Š” ํŒŒ์ผ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ์ถœ๋ ฅํ•ด์ฃผ๋Š” ๋ช…๋ น์ด๋‹ค.
    • sudo yum install lsof ๋ฅผ ํ†ตํ•ด ์„ค์น˜๊ฐ€ ๊ฐ€๋Šฅํ•˜๋‹ค
    • i ์˜ต์…˜์€ IPv4๋กœ ์˜คํ”ˆํ•œ ์†Œ์ผ“์— ๋Œ€ํ•œ ์ •๋ณด๋“ค์ด ๋‚˜์˜จ๋‹ค.

์ฐธ๊ณ ์ž๋ฃŒ

[TIL] ์—๋Ÿฌ๋…ธํŠธ๐Ÿ“• - [Node js] address already in use

[Linux] lsof ๋ช…๋ น์–ด ์‚ฌ์šฉ๋ฒ•

This post is licensed under CC BY 4.0 by the author.

Python์˜ immutable ๊ฐ์ฒด์™€ mutable ๊ฐ์ฒด

Node.js์˜ Express๋ž€?