14,954
edits
| Line 294: | Line 294: | ||
'''Kill the process by port number'''<ref>[https://stackoverflow.com/questions/11583562/how-to-kill-a-process-running-on-particular-port-in-linux How to kill a process running on particular port in Linux? - Stack Overflow], [https://linux.die.net/man/8/lsof lsof(8) - Linux man page]</ref> | '''Kill the process by port number'''<ref>[https://stackoverflow.com/questions/11583562/how-to-kill-a-process-running-on-particular-port-in-linux How to kill a process running on particular port in Linux? - Stack Overflow], [https://linux.die.net/man/8/lsof lsof(8) - Linux man page]</ref> | ||
* {{kbd | key=<nowiki>kill -9 $(lsof -ti:3000) 2>/dev/null</nowiki>}} | * {{kbd | key=<nowiki>kill -9 $(lsof -ti:3000) 2>/dev/null</nowiki>}}: Force kill the process using port 3000. The {{kbd | key=2>/dev/null}} suppresses error messages if no process is found. Replace 3000 with your target port number. | ||
* Alternative (shorter command): {{kbd | key=fuser -k 3000/tcp}} | * Alternative (shorter command): {{kbd | key=fuser -k 3000/tcp}}: Kill the process using TCP port 3000 (if {{kbd | key=fuser}} is available on your system) | ||
Explanation: | Explanation: | ||
* {{kbd | key=<nowiki>lsof -ti:3000</nowiki>}} | * {{kbd | key=<nowiki>lsof -ti:3000</nowiki>}}: Find the process ID (PID) using port 3000 | ||
** {{kbd | key=-t}}: Output only the PID | ** {{kbd | key=-t}}: Output only the PID | ||
** {{kbd | key=-i:3000}}: Filter by port 3000 | ** {{kbd | key=-i:3000}}: Filter by port 3000 | ||