View the port command occupancy
sudo lsof -i :9000
After the colon is the port number you want to view.
TheEternityZhang-MacBook:project zhtony$ sudo lsof -i :8080
Password:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 27374 zhtony 221u IPv6 0x3a877ef28e41f1b3 0t0 TCP *:http-alt (LISTEN)
TheEternityZhang-MacBook:project zhtony$ kill -9 27374
Kill the processes that are currently occupied by the port number
There is a table named head of a PID, this column it means that the process is currently occupied port.
sudo kill -9 27374