how to kill used port

magnet·2021년 11월 4일
0

https://stackoverflow.com/questions/3855127/find-and-kill-process-locking-port-3000-on-mac
를 참조


아하하하하 이미 node.js 사용중에 3000번 포트가 이미 사용중이시랜다~~

Quick and easiest solution:

kill -9 $(lsof -ti:3000)
For multiple ports:

kill -9 $(lsof -ti:3000,3001)
#3000 is the port to be freed

Kill multiple ports with single line command:

kill -9 $(lsof -ti:3000,3001)
#here multiple ports 3000 and 3001 are the ports to be freed

lsof -ti:3000

If the prot is occupied, thie above command will return something like this: 82500 (Process ID)

lsof -ti:3001

82499

lsof -ti:3001,3000

82499 82500

kill -9 $(lsof -ti:3001,3000)

Terminates both 82499 and 82500 processes in a single command.

For using this in package.json scripts:

"scripts": {
"start": "kill -9 $(lsof -ti:3000,3001) && npm start"
}

그냥 죽이자

profile
풀스택을 지향하는 한 발자국씩 삽질하기

0개의 댓글