本篇文章由:http://xinpure.com/nginx-error-upstream-prematurely-closed-connection-while-reading-response-header-from-upstream/

环境描述

Nginx 版本 1.10.2

PHP 版本 7.0.12

Node 版本 5.9.0

本文是想讲一个 Nginx 的错误,为啥还要提及 PHP 和 Node 的版本呢?容我先还原一下应用场景

首先就是我有一个绑定在 3000 端口的 Node Server

我需要从 80 端口直接访问这个服务,所以我使用了 Nginx 的反向代理

而至于 PHP ,其实这个错误就是与它有关

查找错误原因

当我使用这个 Node Server 的时候,返回了一个 502 Bad Gateway 错误

查看网络请求,也没有什么错误,接着就查看了 Nginx error log 里的错误信息

[error] 17028#0: *111 upstream prematurely closed connection while reading response header from upstream

好吧,并不是什么明显的错误提示,只好到 Google 查查看了

查了一番似乎也挺多人遇到这个问题的,但是解决问题的方法好像都不一样。。。

有的说是 keepalive_timeout 值太小了 (这个值我根据服务配置,已经改成 600,感觉不太可能),还有说重启 Nginx 就行了 (尝试过。),等等。。。

当然也有让我眼前一亮的答案,那就是 重启 php-fpm ,果断尝试一下

果然。。。启动报错了,提示大概意思是端口被占用了,瞬间感觉好像找对了突破口

解决错误

看了一下端口才发现,原来是之前已经开启了另外一个 Node Server 占用了 php-fpm 默认的 9000 端口

简直是自己坑自己!

因为服务的端口不能改,要和其它同事的统一,所以我把 php-fpm 的端口改成了 9999

PHP 是使用 brew 安装的,配置路径为: /usr/local/etc/php/7.0/php-fpm.d/www.conf

listen = 127.0.0.1:9999

然后重启 php-fpm 就 OK 了

nginx error: upstream prematurely closed connection while reading response header from upstream的更多相关文章

  1. Nginx" upstream prematurely closed connection while reading response header from upstream"问题排查

    问题背景 我们这边是一个基于Nginx的API网关(以下标记为A),最近两天有调用方反馈,偶尔会出现502错误,我们从Nginx的error日志里看,就会发现有" upstream prem ...

  2. upstream prematurely closed connection while reading response header from upstream

    upstream prematurely closed connection while reading response header from upstream nginx配置uwsgi的时候  ...

  3. 解决flask的502错误:upstream prematurely closed connection while reading response header from upstream

    我在使用 tiangolo/uwsgi-nginx-flask 部署flask应用的时候,经常运行一会儿就出现502错误,重新启动容器后,就恢复. 且经常会出现数据更新后,刷新结果不一致. docke ...

  4. nginx 超时问题: upstream timed out (110: Connection timed out) while reading response header from upstream

    目录 错误内容 错误原因 错误解决办法 错误内容 我们可以在error.log 里面可以看到 错误内容:upstream timed out (110: Connection timed out) w ...

  5. nginx recv() failed (104: Connection reset by peer) while reading response header from upstream解决方法

    首先说下 先看 按照ab 每秒请求的结果 看看 都有每秒能请求几个 如果并发量超出你请求的个数 会这样 所以一般图片和代码服务器最好分开 还有看看io瓶ding 和有没有延迟的PHP代码执行 0 先修 ...

  6. Nginx+PHP配置错误,日志:[error] 24324#0: *31 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

    一.问题现象 1.安装nginx.php.php-fpm后,浏览器访问php报错,“File not found”: 二.问题排查 1.检查nginx.php-fpm服务是否正常启动,均正常启动: 2 ...

  7. recv() failed (104: Connection reset by peer) while reading response header from upstream

    2017年12月1日10:18:34 情景描述: 浏览器执行了一会儿, 报500错误 运行环境:  nginx + php-fpm nginx日志:  recv() failed (104: Conn ...

  8. 修复Nginx 502错误:upstream sent too big header while reading response header from upstream

    原文出处:https://www.cnblogs.com/jpfss/p/10237463.html 便于以后参考我复制了过来! cookies的值超出了范围我是说 看看了一下日志 错误502 ups ...

  9. upstream timed out (110: Connection timed out) while reading response header from upstream

    Nginx报错日志有如下内容: upstream timed out (110: Connection timed out) while reading response header from up ...

随机推荐

  1. ConcurrentHashMap之实现细节

    ConcurrentHashMap是Java 5中支持高并发.高吞吐量的线程安全HashMap实现.在这之前我对ConcurrentHashMap只有一些肤浅的理解,仅知道它采用了多个锁,大概也足够了 ...

  2. jdbc连接rac的oracle数据库

    jdbc连接rac的oracle数据库需要配置所有racIP,如下: DB1 =(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(H ...

  3. php的初步了解

    刚刚学习PHP,在学校中没有接触过这个语言,但是身边的人都说php好,经过这几天的学习,我对它的基础有了一定的认知和了解,php是“PHP Hypertext Preprocessor”的首字母缩写, ...

  4. 列出Windows域中所有的机器

    我所在的部门大概管理了300+台Windows终端,最近开始采用域的方式来进行管理.(别笑我们土,原来手工修改Windows口令太痛苦了.) 现在的任务是想在域控服务器中列出纳入域管理的所有机器,以及 ...

  5. 使用jquery操作iframe

    1. 内容里有两个ifame <iframe id="leftiframe"...</iframe> <iframe id="mainiframe ...

  6. telnet 退出命令

    telnet xxx port ctrl + ] telnet > quit ctrl + w 是清除命令 转自: http://wangyifeng.blog.51cto.com/214490 ...

  7. (转)<Unity3D>Unity3D在android下调试

    转自:http://blog.csdn.net/zuoyamin/article/details/11827309 一.工具准备 1.JDK——由于android是基于Java平台开发的,jdk是必须 ...

  8. freemarker 模板开发入门

    数据模型 scalars标量:从根 root 開始指定它的路径,每级之间用点来分隔. 如:whatnot.fruits sequences 序列:使用数组的方括号方式来訪问一个序列的子变量. 如:an ...

  9. ios Mac 地址获取

    //mac address #include <sys/socket.h> // Per msqr #include <sys/sysctl.h> #include <n ...

  10. STL - 容器 - 运行期指定排序准则

    RuntimeCmp.hpp #include <set> using namespace std; // type for runtime sorting criterion class ...