BaGyun
빠균's 개발노트
BaGyun
전체 방문자
오늘
어제
  • 분류 전체보기 (71)
    • Today I Learned (44)
      • 오류 (8)
      • JavaScript (15)
      • TypeScript (9)
      • NodeJS (0)
      • NestJS (0)
      • Database (3)
      • ORM (1)
      • 알고리즘 (2)
      • 개인공부 (4)
      • Deploy (0)
      • Git (1)
    • 개인프로젝트 (4)
    • 알고리즘 (14)
      • 프로그래머스 (14)
    • 면접질문 (5)
    • 회고 (3)

인기 글

반응형

블로그 메뉴

  • 홈
  • 태그
  • 방명록
hELLO · Designed By 정상우.
BaGyun

빠균's 개발노트

Today I Learned/오류

[Error] 서버 실행 시 발생하는 에러

2022. 7. 8. 16:50

어떤 에러인가요?

서버 실행 후 종료하지 않고 vscode를 껐다가 다시 켜서 서버를 실행하였을 때 발생한 오류

 

에러 메세지

node:events:368
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::4000
    at Server.setupListenHandle [as _listen2] (node:net:1334:16)
    at listenInCluster (node:net:1382:12)
    at Server.listen (node:net:1469:7)
    at Function.listen (/Users/sangkan/Project/Final Project/Dev/NoStanding/server/node_modules/express/lib/application.js:635:24)
    at Object.<anonymous> (/Users/sangkan/Project/Final Project/Dev/NoStanding/server/app.js:34:5)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1361:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'EADDRINUSE',
  errno: -48,
  syscall: 'listen',
  address: '::',
  port: 4000
}
[nodemon] app crashed - waiting for file changes before starting...

에러 핸들링 방법

서버가 올바르게 종료되지 않아 발생한 문제이다.

터미널에서 아래 코드를 입력하여

$ lsof -i TCP:포트번호

가동 중인 서버를 찾고

kill -9 PCI번호
 

위 코드를 입력하여 강제 종료 시킨 후 서버를 재가동 하면 에러가 사라진다.

ex )

~~@~~-ui-MacBookAir ~ % lsof -i TCP:4000
COMMAND   PID    USER   FD   TYPE            DEVICE SIZE/OFF NODE NAME
node    63066 sangkan   22u  IPv6 0x3f076cad4734e4d      0t0  TCP *:terabase (LISTEN)
~~@~~-ui-MacBookAir ~ % kill -9 63066

 

'Today I Learned > 오류' 카테고리의 다른 글

[Error] Missing "driver" option. In the latest version of "@nestjs/graphql" package (v10) a new required configuration property called "driver" has been introduced. Check out the official documentation for more details on how to migrate  (0) 2022.10.19
[Error] Cannot use import statement outside a module  (0) 2022.08.05
[Error] sequelize-auto를 사용했을 때, initModels파일로 테이블들을 Join할 때 마주하는 오류  (0) 2022.07.08
[Error] sequelize-auto를 사용 했을 때, associate 지정을 따로 해주지않고 사용하는 법  (0) 2022.07.08
[Error]Access to XMLHttpRequest at '주소A' from origin '주소B' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.  (0) 2022.07.08
    'Today I Learned/오류' 카테고리의 다른 글
    • [Error] Missing "driver" option. In the latest version of "@nestjs/graphql" package (v10) a new required configuration property called "driver" has been introduced. Check out the official documentation for more details on how to migrate
    • [Error] Cannot use import statement outside a module
    • [Error] sequelize-auto를 사용했을 때, initModels파일로 테이블들을 Join할 때 마주하는 오류
    • [Error] sequelize-auto를 사용 했을 때, associate 지정을 따로 해주지않고 사용하는 법
    BaGyun
    BaGyun

    티스토리툴바