When I’m developing this website I got this message every time I run gatsby develop
command.
Something is already running at port 8000
? Would you like to run the app at another port instead? > (Y/n)
Since it’s rather annoying to press y everytime I want to build it, I learn one trick on how to kill process on localhost with specific port
First, I need to find which process running on port 8000. I can use this command:
lsof -i :8000
lsof
is a command find opened files, socket or network according to Linux man page.
I get the following output.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 23560 nakama 212u IPv4 0x6664bdf40d2e27b7 0t0 TCP localhost:irdmi (LISTEN)
node 23560 nakama 222u IPv4 0x6664bdf410386657 0t0 TCP localhost:irdmi->localhost:64396 (CLOSED)
node 23560 nakama 224u IPv4 0x6664bdf3d078f7b7 0t0 TCP localhost:irdmi->localhost:65170 (CLOSE_WAIT)
Since there’s one PID running on port 8000, I could kill it using
kill -9 23560
Linked Notes:
Today I learn
I believe that we can learn something new everyday, that’s why I set this page to record what I learn during the day.