400 Bad Request
The request has malformed syntax or invalid request message framing.
The server cannot process the request due to a client error.
What HTTP 400 Bad Request Means
The server cannot process the request due to a client error.
The request has malformed syntax or invalid request message framing.
Common Causes
- Invalid JSON/XML syntax
- Missing required parameters
- Malformed request headers
- Invalid query string
How to Fix It (For Visitors)
- Check the URL for typos
- Contact the site administrator
How to Fix It (For Developers/Admins)
- Validate request syntax
- Check API request format
- Review Content-Type header
- Validate JSON payload
Returning a 400 Bad Request (Code Examples)
If you build APIs or web apps, here is how to send an HTTP 400 response and how to test for it:
Node.js (Express)
app.get('/resource', (req, res) => {
res.status(400).json({ error: 'Bad Request' });
});
Python (Flask)
@app.route('/resource')
def resource():
return jsonify(error='Bad Request'), 400
PHP
<?php
http_response_code(400);
header('Content-Type: application/json');
echo json_encode(['error' => 'Bad Request']);
Check the status with curl
curl -I https://example.com/resource
# Look for: HTTP/1.1 400 Bad Request
Frequently Asked Questions
What does HTTP 400 Bad Request mean?
The request has malformed syntax or invalid request message framing. In short: The server cannot process the request due to a client error.
Is 400 Bad Request a client or server error?
400 is a 4xx client-error code, so the request itself needs to change. The server is running normally and is rejecting the request as it was sent by the browser, app, or API client.
How do I fix a 400 Bad Request error?
Validate request syntax. Check API request format. Review Content-Type header.
Official Specification
The 400 Bad Request status code is defined in RFC 7231 Section 6.5.1.