Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django项目的Gunicorn服务器上的连接超时_Python_Django_Gunicorn - Fatal编程技术网

Python Django项目的Gunicorn服务器上的连接超时

Python Django项目的Gunicorn服务器上的连接超时,python,django,gunicorn,Python,Django,Gunicorn,我是Django的新手。我已经完成了民意测验教程,现在正在学习Elman和Lavin的轻量级Django。我目前正在制作一个单文件Django应用程序,如本书第1章所述(链接)-我已经到了第7页。我安装了Gunicorn并运行命令Gunicorn hello--log file=-。一切似乎都正常运行: [2015-07-08 18:13:36 +0000] [9419] [INFO] Starting gunicorn 19.3.0 [2015-07-08 18:13:36 +0000] [9

我是Django的新手。我已经完成了民意测验教程,现在正在学习Elman和Lavin的轻量级Django。我目前正在制作一个单文件Django应用程序,如本书第1章所述(链接)-我已经到了第7页。我安装了Gunicorn并运行命令
Gunicorn hello--log file=-
。一切似乎都正常运行:

[2015-07-08 18:13:36 +0000] [9419] [INFO] Starting gunicorn 19.3.0
[2015-07-08 18:13:36 +0000] [9419] [INFO] Listening at: http://127.0.0.1:8000 (9419)
[2015-07-08 18:13:36 +0000] [9419] [INFO] Using worker: sync
[2015-07-08 18:13:36 +0000] [9422] [INFO] Booting worker with pid: 9422
但是当我导航到104.130.130.222:0000时,我得到一个连接超时错误。我的日志也保持不变。我尝试从不同的网络访问该页面,但没有成功。谁能给我指出正确的方向吗?我对服务器或Gunicorn一无所知,而且我也是Django初学者,所以问题可能很明显——到目前为止,我还没有在互联网上找到任何好的帮助。我正在从运行10.9.5的Mac上远程运行Linux服务器(Red hat 6.4)

我的代码:

 1 # Hello!
 2 
 3 import sys
 4 
 5 from django.core.wsgi import get_wsgi_application
 6 from django.http import HttpResponse
 7 from django.conf.urls import url
 8 from django.conf import settings
 9 
10 
11 def index(request):
12     return HttpResponse('Hello World')
13 
14 settings.configure(
15     DEBUG=True,
16     SECRET_KEY='thisisthesecretkey',
17     ROOT_URLCONF=__name__,
18     MIDDLEWARE_CLASSES=(
19         'django.middleware.common.CommonMiddleware',
20         'django.middleware.csrf.CsrfViewMiddleware',
21         'django.middleware.clickjacking.XFrameOptionsMiddleware',
22     ),
23 )
24 
25 urlpatterns = (
26     url(r'^$', index),
27     )
28 
29 
30 application = get_wsgi_application()
31 
32 if __name__ == "__main__":
33     from django.core.management import execute_from_command_line
34 
35     execute_from_command_line(sys.argv)

我不知道你为什么要去104.130.130.222。服务器正在监听,这是您应该使用的地址。@Daniel Roseman噢,哇,太傻了。这是因为为了绕过我的工作防火墙,当我运行Django runserver命令时,我必须在自己的IP上托管,并在单独的网络上查看。忘记Gunicorn的默认值是127.0.0.1。绑定到我的IP和端口8000,现在可以工作了。