前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SLB和django runserver结合报错问题

SLB和django runserver结合报错问题

作者头像
用户1416054
发布2018-08-02 11:55:06
2.5K0
发布2018-08-02 11:55:06
举报
文章被收录于专栏:JackeyGao的博客JackeyGao的博客

SLB和django runserver结合报错问题

Posted April 24, 2018

SLB 检测流量会使服务器报[Errno 104] Connection reset by peer

Raw

代码语言:javascript
复制
web_1       | ----------------------------------------
web_1       | Traceback (most recent call last):
web_1       |   File "/usr/local/lib/python2.7/SocketServer.py", line 596, in process_request_thread
web_1       |     self.finish_request(request, client_address)
web_1       |   File "/usr/local/lib/python2.7/SocketServer.py", line 331, in finish_request
web_1       |     self.RequestHandlerClass(request, client_address, self)
web_1       |   File "/usr/local/lib/python2.7/SocketServer.py", line 652, in __init__
web_1       |     self.handle()
web_1       |   File "/usr/local/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 140, in handle
web_1       |     self.raw_requestline = self.rfile.readline(65537)
web_1       |   File "/usr/local/lib/python2.7/socket.py", line 480, in readline
web_1       |     data = self._sock.recv(self._rbufsize)
web_1       | error: [Errno 104] Connection reset by peer
web_1       | ----------------------------------------
web_1       | Exception happened during processing of request from ('100.116.165.131', 21753)
web_1       |

由于问题比较紧急, 具体原因没有查。 我直接用 gunicorn 模块启动项目, 完美解决. 试试上跑线上环境不能使用 runserver. 推荐: gunicorn uwsgi.

Bash

代码语言:javascript
复制
pip install gunicorn

gunicorn xxxxxx.wsgi 0.0.0.0:8000

静态文件可以通过 urls.py 生成静态文件 patterns。

Python

代码语言:javascript
复制
from django.contrib.staticfiles.urls import staticfiles_urlpattern

...

urlpatterns += staticfiles_urlpatterns()
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • SLB和django runserver结合报错问题
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档