Nginx 报 500 号错误

2018-01-15 18:01:16 +08:00
 waterlaw

服务端采用 Django + Nginx + Gunicorn 部署, 每次访问 /articles/{id} 这个接口时就报 500/502/504 错误。nginx 错误文件:

2018/01/15 16:49:44 [error] 1006#1006: *1274 upstream prematurely closed connection while reading response header from upstream, client: 27.154.27.176, server: waterlaw.cn, request: "GET /articles/6 HTTP/1.1", upstream: "http://unix:/tmp/waterlaw.cn.socket:/articles/6", host: "waterlaw.cn", referrer: "https://waterlaw.cn/"
2018/01/15 17:07:17 [error] 1006#1006: *1338 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 27.154.27.176, server: waterlaw.cn, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/waterlaw.cn.socket:/", host: "waterlaw.cn"
2018/01/15 17:10:47 [error] 22126#22126: *7 upstream prematurely closed connection while reading response header from upstream, client: 27.154.225.154, server: waterlaw.cn, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/waterlaw.cn.socket:/", host: "waterlaw.cn"
2018/01/15 17:14:26 [error] 22236#22236: *8 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 27.154.225.154, server: waterlaw.cn, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/waterlaw.cn.socket/", host: "waterlaw.cn"
2018/01/15 17:16:03 [error] 22236#22236: *8 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 27.154.225.154, server: waterlaw.cn, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/waterlaw.cn.socket/", host: "waterlaw.cn"
2018/01/15 17:43:44 [error] 22615#22615: *1 upstream prematurely closed connection while reading response header from upstream, client: 27.154.27.176, server: waterlaw.cn, request: "GET /articles/6 HTTP/1.1", upstream: "http://unix:/tmp/waterlaw.cn.socket:/articles/6", host: "waterlaw.cn", referrer: "https://waterlaw.cn/"


Gunicorn 控制台的错误日志:

[2018-01-15 17:51:19 +0800] [22183] [CRITICAL] WORKER TIMEOUT (pid:22730)
2611 次点击
所在节点    Python
7 条回复
alect
2018-01-15 19:34:50 +08:00
upstream 设置的不对吧
Beebird
2018-01-15 19:47:30 +08:00
django 有日志输出吗? 有条件的话试试直接访问 django 的监听端口
beiposhiming
2018-01-15 20:20:55 +08:00
想花式 500 ?
你得跟着 V2EX 多学学😂
flipped123
2018-01-16 09:14:27 +08:00
排查两方面,一个关闭防火墙试试,同时注意关闭 selinux 试试。
zpfhbyx
2018-01-16 09:37:07 +08:00
http://unix:/... 肯定连不上啊。。
xia0pia0
2018-01-16 10:05:37 +08:00
proxy_pass 配错了吧,upstream 那块的问题
waterlaw
2018-01-16 19:37:11 +08:00
不知道是不是文件句柄太多, 每次修改完都再次开启 gunicorn, 然后开了多个进程。 重启一下突然好了, 想到博客用了结巴分词, 然后缓存的时候占用了 1.5 秒。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/423104

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX