How to get running server pid and kill the process?

To get the PID (process ID) of the process running on a particular port in your terminal, you can use the lsof (list open files) command with some additional parameters. For example, to get the PID of the process running on port 3000, you can use the following command:

lsof -i :3000 | awk '{print $2}'

To kill a process in the terminal, you can use the kill command followed by the process ID (PID) of the process you want to terminate.

For example, if the PID of the process you want to kill is 1234, you can use the following command:

kill -9 1234

Leave a Comment

Your email address will not be published. Required fields are marked *