【问题标题】:Django manage.py runserver is not workingDjango manage.py runserver 不工作
【发布时间】:2014-02-17 22:34:19
【问题描述】:

我在尝试使用命令启动服务器时遇到问题

python manage.py runserver 0.0.0.0:8000

正在显示

C:\abc>python manage.py runserver 0.0.0.0:8000
Validating models...

0 errors found
Django version 1.4.9, using settings 'abc.settings'
Development server is running at http://0.0.0.0:8000/
Quit the server with CTRL-BREAK.

但无法通过http://127.0.0.1:8000在浏览器中访问

它正在显示:

Unable to connect

Firefox can't establish a connection to the server at 127.0.0.1:8000.

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.

但是当我尝试相同的时候

python manage.py runserver 

它工作正常。我可以访问应用程序http://127.0.0.1:8000

可能是什么问题。

【问题讨论】:

  • 奇怪它在尝试 python manage.py runserver 0.0.0.0:8080 时对我有用,而不是 python manage.py runserver 0.0.0.0:8000 。端口8000 的一些问题不确定它是否由早期的python manage.py runserver 分配,默认情况下分配8000 端口。我认为不应该。
  • 我不确定这个问题。如果您将服务器作为 python manage.py runserver 0.0.0.0:8000 运行,您可以从 0.0.0.0:8000 访问您的站点
  • 您是否尝试将其关闭再打开?不要误会我的意思 - 端口 8000 可能正在被您的“外部 IP”上的崩溃运行服务器使用
  • 如果@init3是这种情况,那么为什么python manage.py runserver工作正常,它在端口8000http:\\127.0.0.1:8000上运行
  • 是的,你是对的@init3 试过这个C:\Users\15809>netstat -an Active Connections Proto Local Address Foreign Address State TCP 0.0.0.0:4105 0.0.0.0:0 LISTENING TCP 0.0.0.0:4728 0.0.0.0:0 LISTENING TCP 0.0.0.0:7163 0.0.0.0:0 LISTENING TCP 0.0.0.0:8000 0.0.0.0:0 LISTENING TCP 0.0.0.0:8000 0.0.0.0:0 LISTENING TCP 0.0.0.0:47001 0.0.0.0:0 LISTENING

标签: django python-2.7


【解决方案1】:

您的外部 IP 似乎正在使用端口 8000。请查看某个进程是否正在运行并将其终止。

您可以使用netstat -a 检查打开的端口。在 Debian 中,您可以使用netstat -tulpn | grep 8000 获得 PID。最后一行应该显示类似1234/python 的内容。现在用kill 1234 杀死它。

您可以重新启动系统;-)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-27
    • 2020-09-16
    • 2011-02-20
    • 2018-01-23
    • 2020-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多