本篇文章由: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. 在VirtualBox中为已有的磁盘增加磁盘大小

    ①打开CMD,进入到具体虚拟机镜像的存放位置. ②输入命令:VBoxManage modifyhd uuid --resize 25000,这里的25000单位是M,表示修改后的硬盘大小.若是VBox ...

  2. JAVA常见算法题(三十二)---找规律

    题目一: 4,5,15,45,135,405,__ 题目二: 524,244,954,674,394,15,725, __ 题目三: 7,8,6,9,10,7,4,4,5,__ 求横线位置的整数. * ...

  3. 批处理bat一键安装APK

    批处理bat一键安装APK 2018年10月11日 10:48:28 xyzshenxiang 阅读数:77   在安装apk时,每次都得拷贝到手机内存中,然后在手机上操作安装这样做非常不方便,下面介 ...

  4. 【BZOJ】【2741】【FOTILE模拟赛】L

    可持久化Trie+分块 神题……Orz zyf & lyd 首先我们先将整个序列搞个前缀异或和,那么某一段的异或和,就变成了两个数的异或和,所以我们就将询问[某个区间中最大的区间异或和]改变成 ...

  5. [18] 螺旋楼梯(Spiral Stairs)图形的生成算法

    顶点数据的生成 bool YfBuildSpiralStairsVertices ( Yreal radius, Yreal assistRadius, Yreal height, Yuint sli ...

  6. C#中HTML和UBB互相转换的代码

    C#中HTML和UBB互相转换的代码html转UBB的还不是很完美,有空修改,一些代码来自百度谷歌 private string DoHtmlToUBB(string _Html)        {  ...

  7. Cognos Report Studio 链接查询需要注意的地方2

    在Report Studio里面用SQL设计报表,查询2,查询3 要链接一般按条件  a1=b1 在选择链接方式需要注意的地方: 默认链接 外部链接 需要设置打开FM,打开报表设计引用的数据包(FM- ...

  8. (转)NGUI类关系图

  9. java基础-四大特征

  10. 利用js_API 执行对html文档元素的属性的CRUD操作

    转自:http://my.oschina.net/felay/blog/303470 <!DOCTYPE html> <html> <head> <meta ...