重新启动Django服务器会出现以下错误:
this port is already running....
这个问题只发生在Ubuntu上,而不是其他操作系统上。如何释放端口以重新启动服务器?
重新启动Django服务器会出现以下错误:
this port is already running....
这个问题只发生在Ubuntu上,而不是其他操作系统上。如何释放端口以重新启动服务器?
当前回答
ps aux | grep -i manage
after that you will see all process
ubuntu@ip-10-154-22-113:~/django-apps/projectname$ ps aux | grep -i manage
ubuntu 3439 0.0 2.3 40228 14064 pts/0 T 06:47 0:00 python manage.py runserver project name
ubuntu 3440 1.4 9.7 200996 59324 pts/0 Tl 06:47 2:52 /usr/bin/python manage.py runserver project name
ubuntu 4581 0.0 0.1 7988 892 pts/0 S+ 10:02 0:00 grep --color=auto -i manage
kill -9 process id
e.d kill -9 3440
`enter code here`after that :
python manage.py runserver project name
其他回答
如果你在MAC中遇到这个问题,你只需要打开活动监视器并强制相当python,然后再试一次
默认情况下,runserver命令在8000端口上启动内部IP上的开发服务器。
如果要更改服务器的端口,请将其作为命令行参数传递。例如,这个命令在端口8080上启动服务器:
python manage.py runserver 8080
在终端输入ps aux | grep runserver 回车 在结果中使用PID执行kill -9 <PID>
对于实例,如果步骤1的结果如下所示
root 1041 0.0 0.1 266912 34580 pts/3 S+ 11:31 0:01 python3 manage.py runserver 0.0.0.0:3030
root 1696 4.5 0.1 126128 40708 ? S Feb14 925:43 /usr/local/bin/python manage.py runserver 0.0.0.0:8000
1041和1696是pid。我们需要在这些进程中选择我们想要终止的进程。
点击截图中的箭头,找到已经运行Django服务器的bash。您收到此消息是因为您的服务器已经在运行,您试图再次启动服务器。
ps aux | grep -i manage
after that you will see all process
ubuntu@ip-10-154-22-113:~/django-apps/projectname$ ps aux | grep -i manage
ubuntu 3439 0.0 2.3 40228 14064 pts/0 T 06:47 0:00 python manage.py runserver project name
ubuntu 3440 1.4 9.7 200996 59324 pts/0 Tl 06:47 2:52 /usr/bin/python manage.py runserver project name
ubuntu 4581 0.0 0.1 7988 892 pts/0 S+ 10:02 0:00 grep --color=auto -i manage
kill -9 process id
e.d kill -9 3440
`enter code here`after that :
python manage.py runserver project name