Nginx 499 error code

Source: Internet
Author: User

Today, we found that nginx has a lot of 499 errors, accounting for nearly 0.5%, and it was after a new service with upstream was launched.

Grep nginx source code, defined in ngx_request_t.h

 
/** HTTP does not define the code for the case when a client closed* the connection while we are processing its request so we introduce* own code to log such situation when a client has closed the connection* before we even try to send the HTTP header to it*/#define NGX_HTTP_CLIENT_CLOSED_REQUEST 499
 

It is clear that this is a status code defined by nginx, used to indicate such an error: Before the server returns an http header, the client closes the http connection in advance.

Then, in grep, "NGX_HTTP_CLIENT_CLOSED_REQUEST", it is found that the current status value is only assigned in ngx_upstream.

Upstream returns 499 in the following situations:

(1) Before receiving a read/write event, upstream checks whether the connection is available: ngx_http_upstream_check_broken_connection,

If (c-> error) {// connecttion error
...... If (! U-> cacheable) {// The value of cacheable of upstream is false, which is related to the setting of the http_cache module. Indicates whether the content is cached. Ngx_http_upstream_finalize_request (r, u, NGX_HTTP_CLIENT_CLOSED_REQUEST );}}

As shown in the preceding code, 499 is returned when a connection error occurs.

(2) The server does not end processing the request, but the client closes the connection in advance, and 499 is returned.

(3) If an upstream error occurs, when executing next_upstream, the connection is also determined to be available. If the connection is unavailable, 499 is returned.

In short, the increase in the percentage of this error may indicate that the upstream processing on the server is too slow, resulting in the user closing the connection in advance. Under normal circumstances, a small proportion is normal.

Nginx details: click here
Nginx: click here

Deployment of Nginx + MySQL + PHP in CentOS 6.2

Build a WEB server using Nginx

Build a Web server based on Linux6.3 + Nginx1.2 + PHP5 + MySQL5.5

Performance Tuning for Nginx in CentOS 6.3

Configure Nginx to load the ngx_pagespeed module in CentOS 6.3

Install and configure Nginx + Pcre + php-fpm in CentOS 6.4

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.