关于python:在浏览器中打开时Django runserver不响应

Django runserver does not respond when opened in the browser

我已经使用django已有相当长的一段时间了,直到现在我都没有使用它的问题。

当我在终端py manage.py runserver 127.0.0.1:8000中运行时,它显示

Performing system checks...

System check identified no issues (0 silenced). July 23, 2015 -
16:17:23 Django version 1.8.3, using settings 'projectname.settings'
Starting development server at http://127.0.0.1:8000/ Quit the server
with CTRL-BREAK. Performing system checks...

然后当我在浏览器中打开它时,它什么也没有显示。它只是加载和加载。.

我尝试使用Google谷歌搜索,但有人建议我更改端口,所以我更改了它,有人说我将ipaddress与8000以外的其他端口一起使用,但我没有做任何帮助。在加载页面时卡住了。

我正在使用Django 1.8.3。在Windows btw

上运行


尝试绑定到所有网络接口:

1
python manage.py runserver [::]:8000

您应该能够看到它正在监听的端口。转至"开始",然后键入cmd。右键单击cmd,然后以管理员身份运行。然后输入:

1
netstat

您在该列表中看到任何内容吗?

1
TCP    0.0.0.0:8000          YourPC-PC:0          LISTENING

这将是您的网络端口列表中Django运行服务器的列表。


尝试执行以下步骤:

first find the process running on port 8000 by command:

1
netstat -tulpn | grep 8000

take the pid and kill it using command

1
kill pid

run python server using command

1
 python manage.py runserver 0.0.0.0:8000

尝试重新启动计算机。

我在Windows 10机器上发生了同样的事情,同时调试了在flask开发服务器上本地运行的多个API并使用我的Django webapp访问它们。关闭并重新启动Django服务器无济于事,因为它在控制台上未显示任何错误,而webapp页面仍无法加载。重新启动可以消除此问题,该问题可能是由于在调试过程中运行并重新启动多个服务器所引起的。

注意:请确保执行重新启动而不是定期关闭,因为Windows 8默认情况下已启用快速启动。否则,它将仅加载系统的先前状态,并且问题将继续存在。


如果对任何人有帮助。我遇到了同样在Windows上运行的问题,重启Django似乎无济于事。但是,当我查看任务管理器时,似乎还有其他旧的python进程正在运行。在终止这些进程并重新启动Django之后,它开始工作。


如果在远程服务器上运行,请尝试使用0.0.0.0进行操作。

1
python manage.py runserver 0.0.0.0:8000

如果不是,请检查端口是否正在监听。

1
sudo nmap -sT -O localhost #to install=> sudo apt-get install nmap

对于Windows

1
>netstat -a -b