Nginx Error:upstream prematurely closed connection while reading response headers from upstream

Source: Internet
Author: User
Tags node server nginx reverse proxy

This post consists of: http://xinpure.com/nginx-error-upstream-prematurely-closed-connection-while-reading-response-header-from-upstream/

Environment description

Nginx version 1.10.2

PHP version 7.0.12

Node version 5.9.0

This article is to tell a Nginx error, why also mention the PHP and Node version? Let me first restore the application scenario

First, I have a Node Server that's bound to Port 3000.

I need to access this service directly from port 80, so I used the Nginx reverse proxy

And as for PHP, in fact, this error is related to it

Find the cause of the error

When I used this Node Server, I returned a 502 bad Gateway error.

See the network request, there is no error, and then look at the error message in Nginx error log

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

Well, it's not an obvious error, but to Google check.

It seems that a lot of people have encountered this problem, but the solution to the problem seems to be different.

Some say is keepalive_timeout value is too small (this value I according to the service configuration, has changed to 600, feel unlikely), and said restart Nginx on the line (tried. ), etc...

Of course there is a bright answer to my eyes, that is to restart the PHP-FPM, a decisive attempt

Sure enough ... Start error, the hint is probably meant that the port is occupied, the moment feels like looking for the right breach

Resolve Errors

Looked at the port only to find that the original is already opened another Node Server occupies the PHP-FPM default 9000 port

It's a pit of my own!

Because the service port can not be changed, and other colleagues to unify, so I changed the PHP-FPM port to 9999

PHP is installed using brew, the configuration path is:/usr/local/etc/php/7.0/php-fpm.d/www.conf

listen = 127.0.0.1:9999

And then restart the PHP-FPM and it's OK.

Nginx error:upstream prematurely closed connection while reading response headers from upstream

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.