Description of the situation
Due to improper operation, the Django program in the terminal started Python manage.py runserver is not closed (port 8000), again when the terminal starts, an error occurred:
Error:that port is already in use.
Now find the original process and kill the process.
Solutions
1.sudo Netstat-antup
To activate an Internet connection (server and established connections)
The code is as follows |
Copy Code |
Proto recv-q Send-q Local address Foreign address State Pid/program Name TCP 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2206/cupsd TCP 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 1138/postgres TCP 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 1053/named TCP 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 3203/python TCP 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1041/mysqld TCP 0 0 127.0.0.1:20080 0.0.0.0:* LISTEN 3415/ssh TCP 0 0 192.168.1.75:53 0.0.0.0:* LISTEN 1053/named TCP 0 0 127.0.1.1:53 0.0.0.0:* LISTEN 1223/dnsmasq |
The PID number for the process with port number 8000 is found to be 3203
Kill this process with the following command
The code is as follows |
Copy Code |
sudo kill 3203
|
2.sudo lsof-i:8000
The code is as follows |
Copy Code |
COMMAND PID USER FD TYPE DEVICE size/off NODE NAME Python 3632 Ying 3u IPv4 46257 0t0 TCP localhost:8000 (LISTEN) |
Kill the process the same way 1
The code is as follows |
Copy Code |
3.ps aux | grep manage.py Ying 3497 0.0 0.5 67112 23456 pts/26 s+ 10:57 0:00 python manage.py runserver Ying 3498 0.9 0.6 143784 25176 pts/26 sl+ 10:57 0:05/usr/bin/python manage.py runserver Ying 3615 0.0 0.0 15956 932 pts/28 s+ 11:07 0:00 grep--color=auto manage.py |
Kill Process Method Same Method 1