How to detect and solve port occupancy in linux
Sometimes we may find that a program is occupying a port, and we cannot use this port.
We can use two commands to solve this problem.
Find the program
1 | netstat -anp | grep 4000 |
Here we can find the pid 81970 before the program name.
Kill the program
1 | kill -9 81970 |
If the permissions are not enough, add sudo before the command.