Published on 18 February 2020 Tweet
Problem: Sometimes when you start a local node.js server, it may be stuck running at the background. When you try to start the server again, you will hit error saying that the port (for example 8080) is already is in used and locked:
throw er; // Unhandled ‘error’ event
Error: listen EADDRIUSE 127.0.0.1:8080
Solution: You can try to find the process using
lsof -n -i4TCP:8080
8080 with the port number that you want to find. Then you will see a list of processes. Find the process that you want to kill, for example
node is running with PID
6709, then kill that process with command:
Finally, start the server again and it will be running as normal after you free the port in use.
Originally published at https://victorleungtw.com on February 18, 2020.