xxxxxxxxxx
netstat -tulnap // list all ports and processes
netstat -anp|grep "port_number" // show port details
sudo fuser -k Port_Number/tcp // free the port needed
# or
lsof -n -i :'port-number' | grep LISTEN // get port details
# sample response: java 4744 (PID) test 364u IP0 asdasdasda 0t0 TCP *:port-number (LISTEN)
kill -9 PID // free port
1. See all processes listening on port 3000
xxxxxxxxxx
$ lsof -i:3000
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME │
# node 18419 myUserName 20u IPv6 105280 0t0 TCP *:hbci (LISTEN)
2. Kill it
xxxxxxxxxx
$ kill $(lsof -t -i:3000)
The port :3000 should be free. Check it again with $ lsof -i:3000 or try to start your app