1
1
Сегодня натолкнулся на странную ошибку: статус http 499 в логе nginx и отваливание обмена данными между 1c:bitrix и 1c.
Почитал, что такое 499 — соединение было закрыто клиентом.
Действительно, это происходит когда запрос к сайту обрабатывается 25 секунд (предыдущие 0.1 — 0.7 sec).
1. Можно ли как то заставить 1c ждать ответа от сервера чуть подольше (ну хотябы 35 секунд)?
2. В чем может быть дело на сервере? 25 секунд — много.
- Ссылка
When managing and maintaining a website, there are a handful of HTTP status codes to be aware of. Some, such as the HTTP 499 error, can cause a timeout that interrupts your workflow. Therefore, you’ll need to ensure that your site is configured properly to avoid this issue.
Whether you’re seeing the HTTP 499 status code frequently or for the first time, it may indicate an issue with your website that needs to be addressed. The good news is that there are multiple steps you can take to resolve it.
Check Out Our Video Guide to Fixing the 499 Error
In this post, we’ll explain the HTTP 499 status code and what can cause the error. Then we’ll walk you through five potential solutions you can use to fix it. Let’s get started!
What the HTTP 499 Status Code Means
The HTTP 499 status code, also known as a “client closed request,” is a special case of the 502 Bad Gateway Error. It indicates that the client has closed the connection while the server is still processing the request.
HTTP 499 falls within the category of client-based errors. This means the issue is on the client side. Other common errors in this category include HTTP 400 Bad Request and HTTP 404 Not Found. With these errors, the problems are usually easy to define. However, HTTP 499 is more general.
The HTTP 499 error can happen on both Nginx and Apache servers. However, it is more common on Nginx servers because it was created by Nginx.
HTTP 499 is more common on Nginx because the server software handles client connections differently than Apache. With Nginx, each client connection is processed in a separate thread. Therefore, if one client connection takes a long time to process, it won’t slow down the other clients.
However, with Apache, all client connections are processed in the same thread. This can cause problems if one client connection takes a long time to process because it will slow down all other clients.
The HTTP 499 error can cause a timeout that interrupts your workflow- but with a little help from this guide, you can get right back on track 👩💻Click to Tweet
What Causes the HTTP 499 Error
Typically, the HTTP 499 error appears in Nginx logs. This can happen for several reasons, but most commonly, it’s due to either a browser timing out or a user canceling the request.
For example, a website may encounter an HTTP code 499 when it’s loaded with too much traffic. Alternatively, the error can happen when the request comes from algorithms that create issues within the site.
In some cases, this status code may also display when there is no response from the server, and the client has timed out waiting for a response. In these cases, it’s usually best to just try again later. However, if you are consistently getting this status code from a particular server, it may be worth investigating further to see if there is an overarching issue.
How To Fix the HTTP 499 Error (5 Potential Solutions)
Now that we understand more about the HTTP 499 error, let’s look at how to resolve it. Below are five potential solutions for the HTTP 499 status code!
1. Clear Your Browser Cache and Try Again
As we mentioned earlier, this error may be a temporary issue that can be resolved by simply trying to load the page again. It might be that your host or server is overloaded. Therefore, we recommend clearing your browser cache and trying again.
The process for clearing the cache will vary depending on your browser. If you’re using Google Chrome, you can navigate to the three vertical dots in the upper right-hand corner of the window, then go to More tools > Clear browsing data:
You’ll then be prompted to choose which data to clear from your browser cache:
When you’re done, reload your browser. You can also try using a different browser in the meantime. Then revisit your site to see whether the error message is still showing.
2. Disable Your Plugins and Extensions
Some users have reported that certain plugins cause the HTTP 499 status code error. Therefore, we recommend temporarily disabling your plugins to see if this resolves the issue.
You can do this by navigating to your Plugins screen in the WordPress dashboard, selecting all of them, then clicking on Deactivate > Apply from the bulk actions menu:
You can also connect to your site via a File Transfer Protocol (FTP) client or File Manager, then navigate to your plugins folder (wp_content > plugins). Right-click on the plugins folder and rename it to something such as “plugins_old.”
This will deactivate all of the plugins on your WordPress site. You can revisit your website to see whether the error message is still showing. If not, you can try activating your plugins one by one until you find the tool causing the issue.
3. Check Your Error Logs
When troubleshooting the HTTP 499 code, it’s essential to leverage your error logs. This approach will make it easier to narrow down the issue and determine whether it results from a specific plugin or tool.
If you’re not a Kinsta user, you can enable and view error logs by turning on WordPress debugging mode. However, if you’re a Kinsta user, you can quickly and easily see errors in the Log viewer from your MyKinsta dashboard:
You can also check your log files in Nginx (/var/log/nginx.error.log) and Apache (/var/log/apache2/error.log). Furthermore, Kinsta users can take advantage of our analytics tool to take a closer look at errors on your site. Then you can understand how often they’re occurring and whether the HTTP 499 error is an ongoing issue.
4. Use an Application Performance Monitoring (APM) Tool
When managing a website, it’s important to have reliable solutions for identifying and troubleshooting errors on your site. We recommend using an Application Performance Monitoring (APM) tool.
APM tools can help you narrow down which script or plugin may lead to various errors, such as HTTP 499. We include our Kinsta APM, as well as a variety of other DevKinsta tools, with all of our plans:
For example, your APM tool can help you collect valuable data and determine which applications are causing delays. Once enabled, you can use KinstaAPM to view the slowest transactions on your site, trace their timelines, and figure out the causes of issues. Our APM also provides insight into your PHP processes, MySQL queries, external HTTP requests, and more.
5. Contact Your Web Host and Request a Timeout Increase
As we’ve discussed, sometimes HTTP 499 errors can occur when a request is canceled because it’s taking too long. Some hosting providers use a ”kill script”.
In short, a kill script forces a request to be terminated after a certain amount of time. This script is often used in shared hosting environments to prevent long requests from impacting other sites.
If you’re a Kinsta user, this isn’t something you need to worry about. Each site hosted on our platform runs on an isolated software container that includes all resources and software. Everything is completely private, and none of your resources are shared, so we don’t run kill scripts.
However, when it comes to the HTTP 499 error, it’s important to note that the “client” may be a proxy, such as a Content Delivery Network (CDN) or load balancer. A load balancing service can act as a client to the Nginx server and proxy data between your server and users. This can cause a timeout that cancels the request to the Nginx server.
PHP timeouts happen if a process runs longer than the maximum execution time (max_execution_time) or max_input_time specified in your server’s PHP configuration. You may encounter timeouts if you have a busy website or scripts that need longer execution times. Therefore, it might be necessary to extend your timeout value.
Let’s say you have a request that is expected to take 20 seconds to complete. If you have an application with a timeout value of 10 seconds, the application will probably time out before completing the request. You’ll likely see the HTTP 499 status code in such an instance.
Therefore, it’s wise to check with your host about the values set on your server. At Kinsta, the default max_execution_time and max_input_time values are set to 300 seconds (5 minutes). The maximum PHP timeout values vary depending on your plan.
If necessary, you can reach out to your hosting provider to request a timeout increase. As a Kinsta user, you can open a ticket with our support team.
With help from this guide, you can ensure your site is properly configured to avoid seeing this error in the future. ✅ Here’s how… 🚀Click to Tweet
Summary
There are a wide variety of HTTP status codes to be aware of as a website owner. Some of the trickiest are client-based errors, such as the HTTP 499 code. The good news is that you can take a handful of steps to resolve this issue.
In this post, we discussed five potential solutions you can use to fix the HTTP 499 status code error. All of them are viable options; if one doesn’t work, another one should.
Do you want to troubleshoot and resolve issues in WordPress as painlessly as possible? Check out Kinsta hosting plans to learn how our APM tool and other solutions can streamline your website maintenance and management!
Здравствуйте коллеги!
Пишу функционал интернет-эквайринга к банку. В определенный момент (после проведения транзакции) банк POST-ом шлет данные о платеже и, не дожидаясь ответа, закрывает соединение. В результате я не могу словить этот POST, а в логах появляется строчка:
194.190.140.5 - - [12/Feb/2015:11:03:06 +0300] "POST /invoice/getresult HTTP/1.1" 499 0 "-" "HTTP_LIB/1.0" "-"
На сервере CentOS, Nginx в качестве веб сервера, PHP-FPM.
Есть рутовый ssh доступ к серверу и возможность сделать все так как угодно.
Как настроить nginx чтобы принять POST от банка?
Содержание
HTTP-код 499 является специфичным ответом Nginx. Он означает, что установленное соединение было закрыто на стороне клиента. В результате Nginx закрывает соединение с back-end приложением на сервере, что может быть причиной различных проблем.
Изменение поведения
Если необходимо, чтобы в случае закрытия соединения запрос был корректно завершён на стороне back-end приложения, можно использовать один из параметров, в зависимости от того, какой метод связи используется:
proxy_ignore_client_abort on;
fastcgi_ignore_client_abort on;
Источники
Understand the HTTP 499 Client Closed Request error: What are the causes and how to fix it.
Table of Contents
- What is the 499 Client Closed Request error?
- How to fix the 499 Client Closed Request error
-
499 error when the website is behind a proxy
- The right way to set the timeouts
- 499 when your server closed the connection
- How to fix the 499 error when your application dies
- 499 when your server is under a DOS or DDOS attack
- How to fix the 499 error when DOS/DDOS attacks:
-
499 error when the website is behind a proxy
- All HTTP Status Codes
What is the 499 Client Closed Request error?
The 499 HTTP is a non-standard status code introduced by Nginx when a client, for instance a browser, closes the connection while Nginx is processing the request.
There are various reasons why the client would not process the request and ended up with a 499 error code. In the following sections, we will help you identify the different causes and how to fix them in each case.
499 error when the website is behind a proxy
You may find 499 errors when you have a Load Balancing service between your users and your Nginx. A similar situation occurs when your Nginx site is served by a CDN or is behind a WAF (Web Application Firewall).
The 499 error happens when the front server attending your browser request is an Nginx server in reverse proxy mode, and it sends the request to your server site, but your site process exceeds the waiting time of the front server.
To fix this error, you can:
- Increase the processing capacity of your application server. By increasing the “processing power”, you will reduce the waiting time of the Nginx clients in front of your service.
- If you cannot increase the power of your application server, then increase the timeouts of your proxies (load balancer, CDN, firewall, …).
At Wetopi you can increase the size of your server with a single click.
★ Zero-config: configuration files for all server services are transparently adjusted to the power.
The right way to set the timeouts
If there are proxies on your setup such as a “Load balancer”, a Firewall, a CDN, etc, you should set the timeouts so that you timeout first your application server and then the other proxies to the user.
Example:
User → CDN → Nginx Load Balancer → Nginx application → Php_fpm
It’s recommended to set the timeouts like this:
- n seconds to
Php_fpm
timeout.
Set thephp.ini
max_execution_time
and
therequest_terminate_timeout
in yourphp_fpm
config file.
- n+1 seconds to Nginx application timeout.
Set thefastcgi_read_timeout
in your nginx config.
- n+2 seconds to timeout to Nginx Load Balancer
In your location doing theproxy_pass
set the timeouts of:proxy_connect_timeout
proxy_send_timeout
proxy_read_timeout
- n+3 seconds of timeout for your CDN. NOTE: If you can’t set the timeouts of your CDN, then find what is its timeout and adjust the others according to it.
It provides a correct chain of timeouts: Setting an incremental chain of timeouts lets you find who is reaching the timeout.
499 when your server closed the connection
This could be your case, If:
- your site is running with an Nginx server and,
- the request is passed to an application processor e.g.
php_fpm
, or - the request is passed to your API
This setup is configured using the nginx fastcgi_pass
directive.
This 499 error code is produced when your server is too slow.
e.g. your WordPress page process takes too long or freezes
To correct this error, you can:
- Increase the processing capacity of your server. By increasing “processing power”, you will reduce the period Nginx waits.
- If you cannot increase your server power, increase Nginx timeouts with the directive:
fastcgi_read_timeout
.
How to fix the 499 error when your application dies
If your application dies without an answer, the solution could be in your API or CGI code.
NOTE: This is the least common case, PHP and other processors always throw a note to notify a problem. If the app was throwing an error, Nginx would pass you a 5XX error code, not a 499.
If your application freezes, you have 2 options:
- First, tell the Nginx to wait longer. Increase the timeouts of your Nginx by modifying the
fastcgi_read_timeout
. - If waiting longer does not solve the problem, increase the processing capacity of your server.
- If the 499 error occurs on a specific page or request, it could be a “hung” or “code freeze” in your application or content manager. If you use WordPress, check plugin compatibility. If database queries are made, check the good status of tables and indexes.
499 when your server is under a DOS or DDOS attack
There might be a case when someone attacks, and intentionally consumes the server resources. This makes the server unable to process the request and return the result on time.
To verify if this is your case: look at your analytics, and search for spikes in traffic with requests giving the 499 status code:
How to fix the 499 error when DOS/DDOS attacks:
In this case, the best solution is a combination of security measures:
- Prevention: avoid non-legit traffic. You can filter malicious traffic with a combination of public and private blacklists.
- Add infrastructure protection against DOS (Denial of Service) and DDOS (Distributed Denial of Service). Find a hosting provider with infrastructure ready to mitigate this kind of attack.
- Add a protection layer, a security proxy, in front of your server, or
- Add an external security service. A well-known one is Cloudflare. They put a distributed infrastructure in front of your server to fight against DDOS attacks.
At Wetopi, as WordPress specialists, we know how important it is to add strong measures of security.
We apply three techniques to filter traffic:Shared security heuristic learning,
Blacklisting from external sources and
Mitigation of DDoS attacks.
We are techies passionate about WordPress. With wetopi, a Managed WordPress Hosting, we want to minimize the friction that every professional faces when working and hosting WordPress projects.
Not a wetopi user?
Free full performance servers for your development and test.
No credit card required.
All HTTP Status Codes
200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content
207 Multi-Status
208 Already Reported
226 IM Used
300 Multiple Choices
301 Moved Permanently
302 Found
303 See Other
304 Not Modified
305 Use Proxy
307 Temporary Redirect
308 Permanent Redirect
400 Bad Request
401 Unauthorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Timeout
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Payload Too Large
414 Request-URI Too Long
415 Unsupported Media Type
416 Requested Range Not Satisfiable
417 Expectation Failed
418 I’m A Teapot
421 Misdirected Request
422 Unprocessable Entity
423 Locked
424 Failed Dependency
426 Upgrade Required
428 Precondition Required
429 Too Many Requests
431 Request Header Fields Too Large
444 Connection Closed Without Response
451 Unavailable For Legal Reasons
499 Client Closed Request