How to fix 400 Bad Request
Key takeaways
- A 400 Bad Request error is a client-side issue.
- Common causes include incorrect URLs, browser and caching issues, and network problems.
- Website owners should regularly update outdated links to help users avoid 400 Bad Request error.
Have you tried visiting a website when suddenly an error message pops up, saying “400 Bad Request”? Frustrating, right? This is a common client-side error that appears out of nowhere, making you wonder what went wrong.
Let’s discuss what causes this error and what are the effective ways you can do to resolve it.
What does the 400 Bad Request error mean?
The 400 Bad Request or HTTP error 400 is one of many client-side errors that occur when a web server can’t process a client’s request. Unlike server-side errors, the 400 Bad Request is typically caused by the client (you), which means only the client can resolve it. Common causes of a 400 Bad Request error include:
- Incorrect URL
- Corrupted browser cache and cookies
- Outdated DNS cache
- You’re uploading a file that exceeds the site’s file size limit.
Understanding these causes makes it easier to pinpoint and fix the issue.
How to fix 400 Bad Request error
Now that you know what causes a 400 Bad Request error, let’s go through the best ways to fix it.
1. Fix typos in the URL
A simple URL syntax error, such as missing characters or incorrect symbols, can cause a 400 error. So, ensure that what’s in the URL is correctly formatted and follows the proper structure.
Here’s an example:
- Invalid URL format: domain.com/%blog
- Correct URL format: domain.com/blog
URLs use the American Standard Code for Information Interchange (ASCII), where symbols replace spaces and colons (:) to be processed correctly by the server. This is common for longer URLs, especially those containing login details or special characters.
If the URL is incorrect, try using an encoder/decoder tool to restore it to its original format. These tools replace spaces with “%20” and colons with “%3A,” among other things, to make the URL compatible with web standards. After using the tool, re-encode the URL according to the correct syntax.
2. Deactivate browser extensions
Some browser extensions, such as ad blockers, privacy tools (like VPNs), or other add-ons, can interfere with your requests and cause a 400 Bad Request error.
To identify which extension is causing the problem, we suggest you do the following:
For Google Chrome
1. At the top-right corner of your browser, click the three vertical dots to open the menu.
2. Go through the list of options and click Extensions.
3. Then, click Manage Extensions.
4. Deactivate each extension while refreshing the web page with the error to see if the error is still there.
If the HTTP error 400 is gone after deactivating a specific extension, it means that that extension is causing the error.
Note: Don’t forget to re-enable your extensions after troubleshooting.
For Microsoft Edge
1. At the top-right corner of your screen, click the puzzle icon.
2. Then, click Manage Extensions.
3. Deactivate each extension and refresh the web page with the error for each extension to see if the error is still there.
If the error is gone after deactivating an extension, then you can conclude that that extension is causing the error.
3. Clear browser cache and cookies
A 400 Bad Request error can often occur due to outdated browser cache and cookies. Your browser stores these elements to help load websites quickly and remember your preferences. However, if the data becomes outdated, it can lead to errors.
Fortunately, browsers provide an option to clear them. Here’s how.
For Google:
1. Open your browser and go to Settings.
2. Then, go to Privacy and Security.
3. Click Delete Browsing Data.
4. Select Cached Images and Files and Cookies and Other Site Data.
Note: Make sure to uncheck Browsing History if you don’t want to delete your browsing history.
5. Set a preferred time range, but we prefer you set it to the All Time option
6. Finally, click Delete Data.
After this, refresh the page. If the 400 Bad Request is still present, other factors might be causing it.
For Microsoft Edge:
1. At the top-right corner of your screen, click the three horizontal dots to open the menu.
2. Scroll down and click Settings.
3. On the left-hand side, click Privacy, Search, and Services.
4. Navigate the page until you see the Delete Browsing Data tab. It looks like this:
5. Click Choose What to Clear.
6. Make sure to uncheck Browsing History and Download History.
7. Click Clear Now.
After that, refresh the web page with the 400 bad request error.
4. Check file upload sizes
Sometimes, the 400 Bad Request error occurs when you upload a large file to a website. Websites that let users upload files like images, PDFs, or audio files set a required file size. If your file exceeds the limit, the server may reject the request and respond with a 400 Bad Request.
To fix this, try compressing the file to reduce size according to the website’s requirements.
5. Flush your local DNS cache
The Domain Name System (DNS) stores domain names and their corresponding IP addresses. It usually stores this information in your local cache to speed up loading time.
However, when websites change their IP addresses (such as after a server migration), the DNS cache on your device might contain outdated information. When this happens, the DNS records in your local cache become outdated, causing the 400 Bad Request error.
We encourage you to refresh your local DNS cache regularly. Flushing your DNS is an effective step to fix issues related to outdated domain information. To do that, here’s how.
For Windows
- In the Windows Search, type cmd.
- In the command prompt window, type ipconfig /flushdns
- Press Enter.
A confirmation message saying “Successfully flushed the DNS Resolver cache” should appear.
For macOS
Note that this process applies to macOS Big Sur and later versions.
- Through the spotlight search, load the Terminal app.
- Then, type this command:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder - Press Enter.
- Type in your password. Note that you won’t see the characters on your screen.
- Once you’ve typed in your password, press Enter.
Older versions of macOS work with different commands. Try the following.
MacOS Version | Command |
Catalina | sudo killall -HUP mDNSResponder |
Mojave | sudo killall -HUP mDNSResponder |
High Sierra | sudo killall -HUP mDNSResponder |
Sierra | sudo killall -HUP mDNSResponder |
El Capitan | sudo killall -HUP mDNSResponder |
Mavericks | sudo killall -HUP mDNSResponder |
Mountain Lion | sudo killall -HUP mDNSResponder |
Lion | sudo killall -HUP mDNSResponder |
Yosemite | sudo discoveryutil udnsflushcaches |
6. Restart your network and device
In some cases, a bad internet connection causes the 400 Bad Request to pop up. To check if this is the case, try restarting your router, modem, and device. This can help reset network configurations that might be affecting your connection.
If you’re on a shared or public network, try switching to a different connection.
How to audit your website for 400 Bad Request error code
While the 400 Bad Request is a client error, website owners can still take steps to prevent it. How? Through regular website audit.
Visiting your website from different browsers regularly is good practice. See if a 400 Bad Request or other 4xx error pops up. If this happens, go through your website and identify outdated or broken links. If you find outdated links, update the URLs or remove them as needed. This way, you’ll help users avoid clicking on outdated links and navigate your site easily.
Learn more about error codes with Domain.com
Learning to fix the 400 Bad Request error is important for seamless browsing. So, to maintain a seamless experience, it’s beneficial to understand other common HTTP status codes, such as 401 error and 404 error.
By familiarizing yourself with these codes, you can quickly identify and troubleshoot potential problems more effectively. Visit Domain.com now for more informative articles like this.