Django端口被占用Error: That port is already in use.解决方法

Django提示端口被占用“Error: That port is already in use.”,码笔记分享解决方法:

Django端口被占用报错

报错:“Error: That port is already in use.”

解决方法

执行命令:ps aux | grep -i manage,查看占用该端口进程的pid;
然后执行命令:kill -9 进程pid,即可

示例:

Error: That port is already in use.
[root@mabiji HelloDjango]# ps aux | grep -i manage
root      3504  0.1  1.3 241748 25928 pts/1    T    22:01   0:00 python manage.py runserver 0.0.0.0:8000
root      3509  0.2  1.5 318256 29552 pts/1    Tl   22:01   0:00 /usr/bin/python manage.py runserver 0.0.0.0:8000
root      3527  0.0  0.0 112724  1004 pts/1    S+   22:05   0:00 grep --color=auto -i manage
[root@mabiji HelloDjango]# kill -9 3504

如上述例子所示,先执行命令ps aux | grep -i manage查看占用端口的进程pid,然后执行命令kill -9 进程pidkill掉占用该端口的进程。

2024年云服务器租用优惠价格,11月最新: