Last tested: October 22, 2026 · By Alex
A 400 Bad Request error means the server received your request but refused to process it because something in the request itself is malformed, oversized, or invalid. The server is up. The problem is what the browser, app, or script sent.
In practice, most 400 errors I see on real sites come from a short list: bloated or corrupted cookies, a broken URL, oversized headers, an invalid JSON body sent to an API, or a proxy layer (Cloudflare, a load balancer, NGINX) that rejects something the origin would have accepted.
Quick Fix
If You Are a Visitor
- Reload the page and check the URL for typos, stray
%characters, spaces, or unencoded symbols. - Clear cookies for the affected domain only (not your whole browser).
- Try the same URL in a private/incognito window.
- Clear the browser cache and DNS cache.
- If uploading a file, try a smaller file to rule out a size limit.
- Disable browser extensions that modify requests (ad blockers, header editors, VPN extensions).
If You Run the Site or API
- Check the web server error log at the exact time of the error.
- Find out which layer answered: CDN, load balancer, web server, or the application.
- For APIs, validate the JSON body and the
Content-Typeheader, and read the response body for the field that failed. - Roll back the last plugin, rule, or config change if the error started right after it.
What Is 400 Bad Request?

400 Bad Request is an HTTP client error status code. It tells the client that the server cannot or will not process the request because of something perceived as a client error: invalid syntax, invalid framing, a deceptive request, or a request the server simply cannot parse.
It is worth separating it from similar codes:
- 401 Unauthorized means authentication is missing or invalid.
- 403 Forbidden means the request is understood but access is denied (on WordPress, see 403 Forbidden in WordPress).
- 404 Not Found means the request is valid but the resource does not exist.
- 413 Content Too Large means the body is too big.
- 415 Unsupported Media Type means the body is in a format the endpoint does not accept.
- 414 URI Too Long and 431 Request Header Fields Too Large are more specific versions of “your request is too big”.
Many servers do not use the specific codes. NGINX, for example, returns 400 Bad Request — Request Header Or Cookie Too Large instead of a 431. So a 400 is often a generic catch-all for a more specific problem.
What a 400 Error Looks Like
The wording tells you which layer rejected the request, which is half the diagnosis. These are the messages you are most likely to see:
| Message | Usually comes from | Most likely cause |
|---|---|---|
This page isn’t working … HTTP ERROR 400 | Chrome or Edge showing a response with no error page of its own | Any of the causes below; check cookies first |
400 Bad Request — Request Header Or Cookie Too Large | NGINX | Oversized cookies or one very long header |
400 Bad Request — The plain HTTP request was sent to HTTPS port | NGINX | HTTP sent to a TLS port by a proxy or load balancer |
Your browser sent a request that this server could not understand. | Apache httpd | Malformed URL or header; with “Size of a request header field exceeds server limit” it is header size |
Bad Request - Invalid Hostname / HTTP Error 400. The request hostname is invalid. | IIS / Windows HTTP.sys | The Host header does not match any site binding |
Bad Request - Request Too Long | IIS / Windows HTTP.sys | Request headers (usually cookies) are too large |
JSON such as {"code":"rest_invalid_param"} or {"error":"invalid_request"} | An API or application | Invalid body, missing parameter, or bad OAuth request |
Why 400 Bad Request Happens

1. Oversized or Corrupted Cookies
This is the most common cause on WordPress and WooCommerce sites. Plugins, analytics tools, A/B testing scripts, and session handlers keep adding cookies. Once the combined Cookie header exceeds the server buffer, the request is rejected before it reaches PHP. A corrupted cookie value with invalid characters can trigger the same result.
2. Malformed URL
Unencoded characters, a lone % sign, double-encoded strings like %2520, or illegal characters in the path can make the server refuse the request. This often happens when links are copied from email clients or generated by broken code.
3. Headers That Are Too Large
Long Authorization tokens (for example big JWTs), large Referer values, or many custom headers can exceed server limits. Apache and NGINX both have hard limits on individual header lines and on total header size. Servers that support it answer with 431 Request Header Fields Too Large instead.
4. Invalid Request Body
APIs return 400 when the JSON is invalid, a required field is missing, a value has the wrong type, or the Content-Type header does not match the body. The WordPress REST API returns rest_invalid_param or rest_invalid_json with a 400 status in these cases. If the server rejects the format itself rather than its content, you get 415 Unsupported Media Type instead.
5. Plain HTTP Sent to an HTTPS Port
If something sends plain HTTP to port 443, NGINX returns 400 Bad Request — The plain HTTP request was sent to HTTPS port. This usually points to a misconfigured proxy, load balancer, or an upstream that uses http:// for a port that expects TLS. The reverse mistake, a listen 443 directive without ssl, makes browsers show SSL_ERROR_RX_RECORD_TOO_LONG instead.
6. Proxy or CDN Mismatch
Cloudflare, load balancers, and reverse proxies can rewrite or add headers. If the origin receives a Host header it does not recognize, duplicate headers, or a bad X-Forwarded-* chain, it may answer with 400. A request that carries both Content-Length and Transfer-Encoding: chunked is treated as malformed by standards-compliant proxies, including Cloudflare, because the two framing methods contradict each other.
7. Invalid Host Name
Requests that reach a server by IP address, through an old DNS record, or with a typo in a custom Host header can be rejected as an invalid host. IIS is the classic example with HTTP Error 400. The request hostname is invalid, but strict virtual-host setups on other servers behave the same way.
8. Stale DNS or Cache Data
Less often, a browser or OS keeps outdated DNS or cached redirects, and the request lands on the wrong server or with the wrong host name. That server then rejects it.
How to Fix 400 Bad Request Step by Step

1. Check the URL
Look at the address bar carefully. Remove tracking parameters, fix typos, and look for characters like %, {, }, |, or spaces. If the URL came from a link in an email, try opening the page from the site’s navigation instead.
2. Clear Cookies for the Site
Delete cookies for the affected domain only, so you do not get logged out everywhere else:
- Chrome: click the icon left of the address bar, open Cookies and site data (or Site settings), and delete the data for that domain. You can also open
chrome://settings/content/all, search for the domain, and remove it. - Edge: click the icon left of the address bar, open Cookies (or Cookies and site data), and remove the data stored for that domain.
- Firefox: use Settings → Privacy & Security → Cookies and Site Data → Manage Data, search for the domain, and remove it.
- Safari (Mac): open Settings → Privacy → Manage Website Data, search for the domain, and click Remove.
- iPhone and iPad: open Settings → Apps → Safari → Advanced → Website Data (on older iOS: Settings → Safari → Advanced → Website Data) and swipe to delete the domain.
If the error disappears, the cookie size or a broken cookie value was the cause. If it comes back after logging in again, the site itself keeps setting too many cookies, which only the site owner can fix.
3. Test in a Private Window or Another Browser
A private window starts without cookies and without most extensions. If the page loads there, the problem is local to your browser profile. If it fails in every browser and on another network too, the problem is on the server side. Our guide to a website not loading in one browser only covers profile-level causes in more depth.
4. Flush DNS
Clear the local DNS cache to rule out stale records:
# Windows
ipconfig /flushdns
# macOS
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
# Linux (systemd-resolved)
sudo resolvectl flush-caches5. Check the Upload
If the error appears only when submitting a form or uploading a file, retry with a much smaller file. Some proxies and older servers return a generic 400 rather than 413 when the body is too large or the upload is cut off mid-request. On WordPress, see error uploading image in WordPress for the PHP-side limits.
6. Reproduce the Request with curl
curl removes the browser from the equation. Compare a clean request with one that includes your real cookies:
curl -I https://example.com/page/
curl -I -H "Cookie: $(cat cookies.txt)" https://example.com/page/If the clean request returns 200 and the one with cookies returns 400, you have found the cause. For APIs, send the exact payload:
curl -i -X POST https://example.com/wp-json/wp/v2/posts \
-H "Content-Type: application/json" \
-u "user:application-password" \
-d '{"title":"Test","status":"draft"}'Read the response body. The WordPress REST API and most frameworks explain exactly which parameter failed. In the browser, the same information is in DevTools: open the Network tab, click the failed request, and check Response and the request headers.
7. Check Server Logs
On the server, look at the error log at the timestamp of the failure:
# NGINX
sudo tail -f /var/log/nginx/error.log
# Apache (Debian/Ubuntu)
sudo tail -f /var/log/apache2/error.log
# Apache (RHEL/AlmaLinux)
sudo tail -f /var/log/httpd/error_logMessages such as client sent too long header line (NGINX) or Size of a request header field exceeds server limit (Apache) confirm a header size issue. On shared hosting, the logs are usually under Metrics → Errors in cPanel or in the hosting panel’s log section. If the access log shows the 400 but the error log is empty, the application (PHP, Node.js, a framework) generated it; enable its debug log next.
8. Validate API Payloads
Run JSON through a validator or jq before sending it:
echo '{"title":"Test",}' | jq .
# parse error: Expected another key-value pairMake sure Content-Type: application/json is set when sending JSON, and multipart/form-data with a correct boundary when uploading files. Do not set the multipart Content-Type header by hand in fetch(); let the browser add it so the boundary is correct.
9. Check OAuth and Token Requests
Login with Google, Microsoft, or another OAuth provider, and API token endpoints, use 400 for most failures. The JSON body names the problem: invalid_request (a missing or duplicated parameter), invalid_grant (an expired, reused, or wrong authorization code or refresh token), or redirect_uri_mismatch on some providers. Compare the redirect URI character by character with the one registered in the provider’s console, including https, www, and the trailing slash.
10. Review Recent Changes
If the error started after a plugin update, a new CDN rule, or a server config change, roll that change back first. That is faster than debugging blind.
Advanced Troubleshooting
Increase Header Buffers in NGINX
If logs show header or cookie size problems and you control the server, raise the buffer in the http or server block:
http {
client_header_buffer_size 4k;
large_client_header_buffers 8 32k;
}Then test and reload:
sudo nginx -t && sudo systemctl reload nginxRaise the values carefully. Huge limits mask the real problem, which is usually a plugin setting too many cookies. For reference, NGINX defaults are client_header_buffer_size 1k and large_client_header_buffers 4 8k.
Increase Header Limits in Apache
In the main Apache config or the virtual host (these directives do not work in .htaccess):
LimitRequestFieldSize 16380
LimitRequestLine 16380sudo apachectl configtest && sudo systemctl reload apache2Both directives default to 8190 bytes. If a load balancer or CDN sits in front of Apache, raise its limits too, or it will keep rejecting requests that Apache would now accept.
Fix “Plain HTTP Request Was Sent to HTTPS Port”
Make sure the HTTPS server block actually enables TLS:
server {
listen 443 ssl;
http2 on;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
}Also check that your load balancer forwards to the right port with the right protocol. If a proxy talks to this server, its upstream must use https:// for port 443 (for example proxy_pass https://backend:443;), or forward to a plain HTTP port instead.
Check for Bad Rewrite Rules in .htaccess
A rewrite rule that builds an invalid URL can produce 400 responses. Temporarily rename .htaccess and restore the default WordPress block to test:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPressRewrite loops usually show up as ERR_TOO_MANY_REDIRECTS rather than 400, so if you see that instead, start there.
Find Out Which Layer Returned the 400
Compare the response headers through the CDN with a request sent straight to the origin:
# through the CDN
curl -sI https://example.com/page/ | grep -iE "^(HTTP|server|cf-ray)"
# straight to the origin (replace with your server IP)
curl -sI --resolve example.com:443:203.0.113.10 https://example.com/page/ | grep -iE "^(HTTP|server)"If the origin answers 200 and only the CDN path fails, the problem is in the CDN or proxy rules. If both fail, look at the origin logs.
WordPress-Specific Causes
- Cookie bloat: WooCommerce, membership plugins, and marketing tools can stack cookies. Audit them in DevTools → Application → Cookies and remove plugins you no longer need.
- REST API requests: Gutenberg, page builders, and headless frontends call
/wp-json/. A 400 there usually comes with a JSON error code that names the problem; see WordPress REST API error for the full checklist. - admin-ajax.php: A 400 with the body
0fromadmin-ajax.phpmeans no handler is registered for theactionparameter. Usually a deactivated plugin or a missingwp_ajax_nopriv_hook for logged-out users. - Security plugins: Some firewall plugins return 400 for requests they consider suspicious. Check their logs before changing server settings.
The Cloudflare Angle
If the error page shows Cloudflare branding, check whether Cloudflare or the origin generated it. According to Cloudflare’s documentation, request headers have a total limit of 128 KB and URLs a limit of 16 KB. Most origin servers have much lower limits (NGINX and Apache work with 8 KB per header line by default), so in practice a 400 about header or cookie size behind Cloudflare almost always comes from your server, and Cloudflare just passes it through.
Cloudflare itself returns 400 for requests that are malformed at the protocol level, for example special characters that are not properly URL-encoded, or a request with both Content-Length and Transfer-Encoding: chunked. When you use the Cloudflare API, a 400 means the syntax, parameters, or body of the API call are wrong.
Useful checks:
- Pause Cloudflare temporarily or test the origin directly with
curl --resolve example.com:443:ORIGIN_IP https://example.com/. - Review Security → Events for blocked requests and the rule that matched.
- Check Transform Rules and Workers that modify headers.
- If the origin fails with 400 while Cloudflare shows an Error 520, the origin is sending a malformed or empty response rather than rejecting the request.
Prevention Tips
- Keep the number and size of cookies small. Remove unused tracking scripts.
- URL-encode all user input and dynamic parameters in links.
- Validate API payloads on the client before sending them.
- Return clear JSON error messages from your own APIs so a 400 explains which field failed.
- Keep header buffers on all layers (CDN, load balancer, NGINX, Apache) consistent so one layer does not reject what another accepts.
- Test config changes with
nginx -torapachectl configtestbefore reloading. - Monitor 4xx rates in logs so a new spike after a deployment gets noticed quickly.
When to Contact Support
Contact your host or the site owner if the error appears in every browser and on every device, clearing cookies does not help, and you have no access to server configuration. Send them the exact URL, the time of the error with your time zone, and the response headers from curl -I. On shared hosting, header buffer limits can only be changed by the provider.
Frequently Asked Questions
The server received the request but could not process it because something in the request is invalid: a malformed URL, oversized or corrupted cookies, headers that are too large, or an invalid request body.
It is a client-side error code, so start with your browser: check the URL, clear the site’s cookies, and try a private window. If it happens for everyone, the cause is on the server, CDN, or proxy configuration.
When the combined Cookie header grows past the server’s header buffer, or a cookie value is corrupted, the server rejects the request. Deleting the site’s cookies makes the request small and valid again.
Reduce cookies first. If you control the server, raise large_client_header_buffers (for example 8 32k) in the http or server block, then run nginx -t and reload NGINX.
Sometimes. Cloudflare returns 400 for protocol-level problems such as unencoded special characters or conflicting Content-Length and Transfer-Encoding headers. Its header limit is 128 KB in total, so header and cookie size errors usually come from the origin server behind it.
A 400 means the request itself is broken, so the server will not process it at all. A 404 means the request was valid but nothing exists at that URL. Fixing a 400 means changing what is sent; fixing a 404 means changing the URL or restoring the page.
Final Thoughts
A 400 Bad Request is the server saying “I can’t read what you sent.” Start on the client side: check the URL, clear site cookies, and retest in a private window. If you own the site, reproduce the request with curl and read the error log. That combination finds the cause in most cases within minutes, whether it is cookie bloat, a broken API payload, or a mismatched proxy layer.
Related HTTP Errors
- 431 Request Header Fields Too Large
- 414 Request-URI Too Long
- 413 Request Entity Too Large
- 415 Unsupported Media Type
- 405 Method Not Allowed
- 401 Unauthorized
- 404 Not Found
- How to Fix Website Errors (full guide)
Hi, I’m Alex — the person behind ErrorRescue.
I’ve been working with websites, servers, and hosting for over 8 years. Most of my experience comes from troubleshooting real problems on WordPress sites, VPS and shared hosting environments, and Cloudflare setups. I’ve dealt with everything from SSL certificate failures and DNS misconfigurations to 504 timeouts, memory exhaustion errors, and Cloudflare 5xx issues.
I started ErrorRescue because I got tired of seeing generic, outdated, or incomplete error guides. My goal is to write clear, practical fixes based on what actually works in production — not just theory. Every guide here is tested against common server setups (Apache, NGINX, Cloudflare, and popular WordPress stacks).
When I’m not fixing sites, I’m usually reviewing new hosting configurations or updating existing guides so they stay accurate.
