How do I fix this HTTP Error 400 the size of the request headers is too long?

The size of The Request Headers is Too Long. If The length of The Request headers received in IIS7/7.5 exceeds 16K (The default value), an Error is raised.
I wrote a blog post about this problem (Bad Request-Request Too Long caused by statistics code of CNZZ). The reason for the problem is that the statistics code of third-party statistics service CNZZ writes a large number of cookies, which are carried when requested, resulting in the Request header length exceeding the limit.
I thought this was a problem only for Chrome, but then I got feedback from friends that it was also a problem for Firefox. So, to solve this problem, you have to start at the server end, and this article shares how to start at the server end.
where
According to The IIS forum post (HTTP 400. The size of The Request Headers is Too long), The 16K request header/request length limit is determined by two Parameters in the registry (HKEY_LOCAL_MACHINE\System\ Services\HTTP\Parameters) MaxFieldLength (request header) and MaxRequestBytes (request header and request body). So, you start with these two parameters.
Know your target
Through the Microsoft official documentation (//support.microsoft.com/kb/820129) to learn more about MaxRequestBytes and MaxFieldLength:
MaxFieldLength – Sets an upper limit for each header.
Used to set the maximum number of bytes per request header (default 16K).
MaxRequestBytes – Determines the upper limit for the total size of the Request line and the headers.
Used to set the maximum total number of bytes between the request line (the body of the request) and the request header (16K by default).
How to start
Start by adjusting the values of MaxFieldLength and MaxRequestBytes (assuming 32K) to take effect.
Run regedit, go to HKEY_LOCAL_MACHINE\System\ Services\HTTP\Parameters,
1. Add an item of type DWORD(32-bit) with the name MaxFieldLength and the value decimal 32768;
2. Add items of type DWORD(32-bit), named MaxRequestBytes, value decimal 32768.


Ok, so how do we get them to work?The easiest thing to do is reboot, but the last thing you want to do with a server is reboot.
Fortunately, the solution to this problem is mentioned in the Official Microsoft documentation. You need to run four commands:

Net stop HTTP
net start HTTP
net stop iisadmin /y
net start servicename

But the third command, NET Stop iISadmin, will disable all services related to IIS, and the fourth command will start all services related to IIS one by one.
Although there is no need to restart the server, I don’t like the solution of these four commands… I couldn’t find a better solution on the Internet…
Then, by trial and error, I found an even simpler method that required only three commands:

net stop http
net start http
iisreset

This method has been validated in practice on the server.

Read More:

Client-server interactions tend to happen incessantly and smoothly. Despite this, a 400 Bad Request error usually indicates a request that hasn’t been met successfully, or could mean that the remote server you sent your request to could not understand the request as it became corrupted.

Malformed requests can result in error messages as servers respond to requests in a specific and often fixed format. To add to the confusion, sometimes the server itself may cause the error but only in select few instances. Depending on the browser you’re using, HTTP errors may also appear differently.

When it comes to Firefox and Safari, they usually display a blank page with no status code. Chrome, on the other hand, shows a generic “This page isn’t working” message along with an error code.

Here you can find a list of the most common error messages that users have reported while facing a 400 Bad Request error:

  • Bad Request - Invalid URL
  • Bad Request: Error 400
  • HTTP Error 400 - Bad Request
  • HTTP Error 400. The request hostname is invalid
  • Bad Request. Your browser sent a request that this server could not understand

Website owners may also opt to customize their HTTP Error 400 page to ensure reliable hosting services. An example of this is when web servers run Microsoft Internet Information Services (IIS) they show a more specific variant of the error such as “400.3: Invalid If Header”, “400.2: Invalid Depth Header”, “400.1: Invalid Destination Header”, and more.

A number of scenarios can lead to a 400 Bad Request error, although it may not be immediately apparent. Find out about the most common causes of the error and how to fix them below.

HTTP error 400 causes

There’s a variety of issues that can lead to a 400 Bad Request error. Here, we’ll go over five common issues.

1. Bad URL Syntax

A 400 Bad Request error is usually a client-side error. A good case in point is a URL string syntax error. Incorrectly typed URLs, or URLs that contain backslashes and other invalid characters can garble a request. 

For example, the following URL will send you to a valid page.

//www.itpro.com/network-internet 

Access the same URL with an extra “%” in it, and your browser will throw a 400 Bad Request error. 

//www.itpro.com/%network-internet

2. Invalid Cookies 

Cookies store information about the websites you visit and may also store authentication data to speed up log in. If you can’t log into a website you previously visited, it means the cookie containing your log in data is no longer valid. This results in a 400 Bad Request error.

3. Incorrect file size

You may be trying to upload a file that’s too large to a website. The server will fail to fulfill your request and respond with a 400 error message in such a case. 

Keep in mind, the hosting provider sets the maximum upload size limit at the server level. For example, the maximum file size limit for WordPress ranges from 4MB to 128MB.

4. Unsynchronized DNS Cache

Browsers read domain names as IP addresses, which are stored locally in the Domain Name System (DNS) cache to improve the browsing experience. A 400 Bad Request error can occur when the DNS data stored locally is out of sync with a website’s registered DNS information during a future interaction.

5. Server error

Servers can cause errors too. To check if there's an issue with the server, try loading a website from a different browser and device. If the website fails to open in Edge, Chrome, Firefox, or IE, it's likely a server-side problem. 

How to fix a 400 Bad Request?

It’s hard not to be unfazed by an HTTP error that tells you little about the problem. That said, fixing a 400 Bad Request error takes just a few steps. We’ve put together a few useful tips below to help you find your way out.

1. Recheck the URL

Since a malformed URL is the most common cause of the 400 Bad Request error, make sure there are no typing or syntax errors in your URL. Alternatively, for long URLs, consider using an online URL encoder, which automatically detects non-ASCII characters or invalid characters in a URL, saving you time and effort.

2. Check your internet connection

If you keep seeing a 400 Bad Request on nearly every website you visit, check your internet connection or consult your internet service provider to rule out a poor connection.

3. Clear browser cookies 

A website may fail to comply with your request due to old or corrupt cookies. As a quick fix, consider clearing your browser cache and cookies. Repeat this exercise from time to time to avoid running into a 400 Bad Request error.

4. Clear DNS Cache

This works similar to clearing browser cookies and cache, except that it’s locally stored in your computer and may contain outdated information that doesn’t sync with the current webpage. You can clear old DNS information and records from your system within the Command Prompt in Windows and Mac.

5. Compress the file

If you run into an HTTP Error 400 right after uploading a file, try uploading a smaller file. If that works, you may conclude that the initial file exceeded the server limit. The best workaround for uploading a large file is to compress it. Most websites permit zip files that fall under the maximum upload size.

6. Deactivate browser extensions

While this isn’t a common solution for a 400 Bad Request error, some browser extensions may interfere with cookies. Temporarily disabling them might resolve the problem.

7. Restart your system

If you’ve attempted all of the above fixes and the HTTP Error 400 still persists, you might want to try the good old reboot. Although often ridiculed, turning a device off and on again is surprisingly efficient in resolving an array of issues. With the HTTP Error 400, you will want to not only restart your computer but any attached peripherals – especially routers – as well. 

Related Resource

The top three IT pains of the new reality and how to solve them

Driving more resiliency with unified operations and service management

Free download

However, if this magic fix fails is as inefficient in solving the error as the previous six methods, it might not have anything to do with you nor your devices. In some instances, an HTTP Error 400 is actually caused by a server-end issue, which in turn can be anything from data centre power cuts to an overheated or excessively humid server room environment. In short, there is little to nothing that you can do to fix a server-end issue, and there are likely multiple people working to resolve it for you. In most cases, however, a client-side HTTP error status code starts with 4, while a server-side HTTP status begins with 5. 

Nevertheless, reporting the problem might bring some solace, and could help provide a better estimate of how many users are affected. This can be done by filing a report directly to the administrator of the page, or simply logging it on a monitoring site such as Down Detector.

At the end of the day, the HTTP Error 400 is very much like other HTTP errors in the way that its causes are often mysterious as well as baffling. In many cases, they can be traced back to a rather uncomplicated issue, such as expired browser files and cookies, wrongly inserted URLs, or even an incorrect file size.

Featured Resources

The COO's pocket guide to enterprise-wide intelligent automation

Automating more cross-enterprise and expert work for a better value stream for customers

Free Download

Introducing IBM Security QRadar XDR

A comprehensive open solution in a crowded and confusing space

Free Download

2021 Gartner critical capabilities for data integration tools

How to identify the right tool in support of your data management solutions

Free Download

Unified endpoint management solutions 2021-22

Analysing the UEM landscape

Free Download

What does it mean by HTTP error 400 a request header field is too long?

The "Request header too large" message is thrown with an HTTP error code 400. This error occurs if the size of the request header has grown so large that it exceeds the maximum-allowed size. We recommend that you use the latest version of the SDK. Use at least version 3.

How do I get rid of bad request header fields too long?

If you see the following error when trying to log into University Services with Google Chrome: Bad Request - Request Too Long HTTP Error 400 Try the following: Clear the browser cache completely. Clear the browser cookies. Restart the browser and try again.

How do I fix HTTP error 400?

How to fix a 400 Bad Request?.
Recheck the URL. Since a malformed URL is the most common cause of the 400 Bad Request error, make sure there are no typing or syntax errors in your URL. ... .
Check your internet connection. ... .
Clear browser cookies. ... .
Clear DNS Cache. ... .
Compress the file. ... .
Deactivate browser extensions. ... .
Restart your system..

How do I fix the header is too large?

For Google Chrome You can fix the “ 400 Bad Request. Request Header Or Cookie Too Large” by checking and deleting the cookies of that particular domain in the cookie section of the Chrome.

Toplist

Neuester Beitrag

Stichworte