微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法连接到 http://127.0.0.1:8000/

如何解决无法连接到 http://127.0.0.1:8000/

我使用了与教程相同的代码 drf website

当我跑步时

python manage.py runserver

它在终端中给了我这个

    Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
July 10,2021 - 07:12:08
Django version 3.2.5,using settings 'drftut.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Firefox 给了我这个错误

连接超时

位于 127.0.0.1 的服务器响应时间过长。

The site Could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages,check your computer’s network connection.
If your computer or network is protected by a firewall or proxy,make sure that Firefox is permitted to access the Web.

我也在使用 wsl1 和 vscode 远程桌面来实现 wsl,并且我在 python 环境中运行它

解决方法

kill $(lsof -t -i:8000) 在终端或 cmd 中使用此命令来终止已经在 PORT 8000 上运行的进程。 如果这也不适合您,请尝试在另一个端口上运行服务器,例如 python manage.py runserver 5000 或任何其他空闲端口

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。