How to fix a “400 Bad Request” error with 5 easy methods

How to fix a “400 Bad Request” error with 5 easy methods

When you attempt to access a website, your browser sends a request to the server, which then sends back a response. However, if there’s an error in the request, the server may send an invalid response like the “400 Bad Request” error.

The most common “400 Bad Request” causes are:

  • Corrupted browser cache. Using corrupted cache files in a request may cause the server to misinterpret it, leading to a 400 error.
  • Invalid request message framing. Software bugs or data corruption causing deviations may lead to unprocessable requests by the server.
  • Malformed request syntax. Incorrect syntax, ranging from typing errors to flawed application logic, can render the request invalid to the server.
  • Invalid characters in URLs. Invalid characters in a URL, like encoding errors or incorrect character escaping, can prompt a 400 error.
  • Deceptive request routing. Faulty routing of requests through networks can cause mismatches. Client input may not match what the server receives, which can lead to errors.
Error code400 Bad Request Error
Error typeClient-Side
Error variationsHTTP Error 400
HTTP Error 400 – Bad Request
HTTP Error 400. The request hostname is invalid
HTTP Status 400 – Bad Request
400 Bad Request
400 – Bad Request. The request could not be understood by the server due to malformed syntax. The client should not repeat the request without modifications.
400 Bad Request. Request Header Or Cookie Too Large
Bad Request – Invalid URL
Bad Request – Error 400
Bad Request – Your browser sent a request that this server could not understand
Error causesCorrupted cache or cookies
Invalid request format
Malformed request syntax
URL string syntax error
Bad DNS cache
Hostinger web hosting banner

How to fix a “400 Bad Request” error

If you encounter a 400 error, it’s wise to start with the simplest steps, such as refreshing the page or checking your internet connection. If the error persists, proceed with more in-depth methods below.

1. Double-check the URL

Incorrectly entered or formatted URLs are common causes of the “400 Bad Request” error. Therefore, one of the simplest ways to address this issue is to check if the URL is correct.

Pay attention to these common URL errors:

Typing mistakes

Spelling errors in the domain name or URL path can lead to this error. For example, typing www.hostinger.com/totorials instead of www.hostinger.com/tutorials.

Incorrect use of special characters

URLs may contain special symbols like the hyphen () or percentage (%) for specific formatting purposes. Incorrectly including or omitting these characters can lead to problems.

For instance, www.hostinger.com/%tutorials consists of an extra percentage, which can trigger a 400 error.

Incorrect use of special characters when accessing a website causes the 400 Bad Request error

Badly encoded URLs

URLs commonly use ASCII character encoding for transferring data on the internet. A typical encoding example is replacing a space with %20.

Improper encoding, such as using double percentage characters (%%), can result in syntax errors. An example of an improperly encoded URL is www.hostinger.com/tutorials%20%%20example.

If you suspect that the URL is incorrectly encoded, use an encoder/decoder tool to decode the URL back to its original format. Then re-encode it with the proper syntax and format.

2. Clear browser cache and cookies

The browser cache locally stores data files like texts and images on the client’s side. This helps reduce server requests and speeds up page loading. Meanwhile, cookies track the user’s session history, login details, and preferences for personalized browsing experiences.

However, cache and cookies can become corrupted or outdated, leading to a browser error. Additionally, if the browser sends cookie data that exceeds the allowed file size, it can trigger a specific status code like 400 Bad Request – Request Header Or Cookie Too Large.

If you use Google Chrome, follow these steps to clear your browser’s cache:

  1. Click on the three dots in the top right corner of Google Chrome and select Settings.
  2. Find the Privacy and security section and click on Clear browsing data.
Accessing the Clear browsing data menu on Google Chrome
  1. In the Clear browsing data window, ensure Cached images and files and Cookies and other site data are checked. Then, select the desired time frame for deletion.
  2. Click on Clear data. After completing this step, restart Google Chrome.
Selecting the Clear data button on Google Chrome

For other browsers, the process is similar but may vary slightly in terms of navigation.

Please note that clearing cache and cookies will sign you out of most websites and may reset some settings. Initially, websites might load more slowly as your browser will need to redownload content that was previously stored in the cache.

After completing these steps, try reaccessing the website. If the “400 Bad Request” error persists, try another method.

3. Turn off browser extensions

Although extensions enhance browser functionality, they can sometimes conflict with certain websites, leading to errors.

Moreover, some extensions interact directly with cookies or other site data. Malfunctions or outdated versions of these extensions can trigger a 400 error.

For Chrome users, here are the steps to deactivate browser extensions:

  1. Click on the three dots in the top right corner and select Extensions.
  2. You will see a list of all installed extensions. Turn off each extension by clicking on the toggle switch beside it.
Disabling an extension on Google Chrome
  1. After turning off all extensions, refresh the web page that was displaying the 400 error. If the page loads correctly, this suggests that one of the extensions was causing the problem.
  2. Re-enable the extensions one by one, refreshing the page after each activation. If the 400 error reoccurs, the most recently enabled extension is likely responsible.
  3. Try updating the problematic extension to see if this resolves the issue. If the problem continues, you may need to remove the extension by clicking the Remove button.
Removing an extension on Google Chrome

4. Clear DNS cache

The web server’s information is stored in a local cache. This speeds up loading on repeat visits by reducing DNS lookup times. However, outdated or corrupted cached data can lead to issues, including the HTTP error “400 Bad Request”.

Here are the steps to flush the DNS cache on different operating systems:

Windows 11

  1. Right-click on the Start menu and select Windows Terminal (Admin) or Command Prompt (Admin).
  2. Type ipconfig /flushdns in the command prompt window and press Enter.
  3. A confirmation message should appear, indicating that the DNS resolver cache is successfully flushed.

This DNS cache flushing method works similarly on Windows 10, 8, and 7.

macOS 14 Sonoma

  1. Navigate to Applications → Utilities → Terminal. Alternatively, use Spotlight search (Cmd + Space) to find it.
  2. Write sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder and press Enter.
  3. Enter your administrator password when prompted. Note that it will not be visible as you type.

The command is also effective in several previous versions, including macOS Catalina, Mojave, and High Sierra.

For Google Chrome users, you’ll also have to flush the outdated DNS cache in the web browser. Here’s how:

  1. Type chrome://net-internals/#dns in the address bar and press Enter.
  2. Click on Clear host cache to flush the DNS cache within Chrome.
Clearing the host cache on Google Chrome

By clearing the local DNS cache, your system will retrieve the most up-to-date DNS information for websites, potentially resolving request issues.

5. Check if the file size exceeds server limits

Web servers usually set a maximum upload limit to manage data transfer efficiently. One commonly overlooked cause of the “400 Bad Request” error is attempting to upload a file that is larger than the server file size limit.

Begin by checking the website server limit for uploading files. This information is often found in the website’s FAQ or help section. If it’s not clearly stated, contact the website administrator or refer to the server or web hosting provider’s documentation.

Determine the file size of the file you are trying to upload. If it exceeds the server’s limit, it’s likely the cause of the “400 Bad Request” error. If unsure, test by uploading a smaller file. If the smaller file uploads without issue, then the size of the original file is the problem.

Consider compressing documents and images to reduce their file sizes. For videos or audio files, try using a format with higher compression or splitting the file into smaller parts.

There are many free file compression online tools that don’t require installing additional software. Examples include HiPDF for PDF files, TinyPNG for images, and Media.io for video and audio files.

Compressing a PDF file with HiPDF

Remember, compressing a file can affect its quality. A poorly compressed PDF or image can become blurry or unreadable. Always check the quality of the compressed file to ensure it remains suitable for your needs.

For website owners, uploading files that exceed your server limit could also lead to a 413 Request Entity Too Large error. Thus, understanding and managing file sizes in accordance with server limits is key to preventing both types of errors.

“400 Bad Request Error” on different browsers

The 400 status code may be displayed differently across various web browsers. Here are some examples:

Google Chrome

Chrome shows an error icon alongside the error message The page isn’t working. It also suggests contacting the site owner if the problem persists. This is followed by HTTP ERROR 400 at the bottom.

The HTTP error 400 on Google Chrome

Microsoft Edge

Microsoft Edge features an error page that’s almost identical to Google Chrome’s, displaying the HTTP ERROR 400 text at the bottom.

The HTTP error 400 on Microsoft Edge

Opera

Opera presents the same message as Google Chrome for the HTTP “400 Bad Request” error, with the only difference being the use of Opera’s logo as the icon.

The 400 Bad Request error on Opera

Mozilla Firefox

Firefox typically shows a blank page without any text indicating a “400 Bad Request” error. This can make identifying the problem more challenging.

A blank page indicating a 400 Bad Request error on Mozilla Firefox

Safari

Similar to Firefox, Safari often displays a blank page with no clear indication of the HTTP “400 Bad Request” error.

A blank page suggesting an HTTP 400 Bad Request error on Safari

Furthermore, many websites customize their 400 status code. For example, Google has a distinct 400 Bad Request error page that appears consistently across all web browsers.

Google's customized 400 error page

Conclusion

In this article, we have explored five methods to fix the “400 Bad Request” error. They range from easier steps like refreshing the page and double-checking URLs to more technical methods such as clearing the browser’s cache and cookies, deactivating extensions, and flushing the DNS cache.

Try each one out, and let us know which one worked for you.

“400 Bad Request” FAQ

Is a “400 Bad Request” error a client-side or server-side issue?

The “400 Bad Request” is primarily a client-side error. It often occurs due to a client request mistake, such as incorrect syntax, invalid request headers, or oversized file uploads.

What are some of the best practices for avoiding a “400 Bad Request” error?

Ensure accurate and proper URL formatting, regularly clear your browser’s cache and cookies, and keep file sizes within the server’s upload limits. Additionally, verify that request headers are correctly formatted and avoid using invalid or non-standard characters in URLs.

Are there any tools that can help me debug a “400 Bad Request” error?

Browser developer tools like Chrome DevTools can help in debugging “400 Bad Request” errors, as well as other HTTP issues. They allow inspection of HTTP requests and responses to identify issues with request formatting, rates, and methods. If you run a WordPress website, follow our guide to enable WordPress debug mode.

Author
The author

Leonardus Nugraha

Leo is a Content Specialist and WordPress contributor. Armed with his experience as a WordPress Release Co-Lead and Documentation Team Representative, he loves sharing his knowledge to help people build successful websites. Follow him on LinkedIn.

Author
The Co-author

Ariffud Muhammad

Ariffud is a Technical Content Writer with an educational background in Informatics. He has extensive expertise in Linux and VPS, authoring over 200 articles on server management and web development. Follow him on LinkedIn.