500 Internal Server Error
Example HTTP Response
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
{"error": "Something went wrong"}- Unhandled exception in code
- Database connection failed
- Server misconfiguration
What does this mean?
Oops, we broke it! The server had a little meltdown. It's not you, it's definitely us.
Technical Definition
The server has encountered a situation it doesn't know how to handle.
RFC Says
"The 500 (Internal Server Error) status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request."
Plain English:
Something unexpected went wrong on the server. This is a catch-all for server errors that don't fit into more specific categories. It's the server saying 'I messed up, but I'm not sure exactly how.'
Common Misinterpretation
Developers often overuse 500 for all server-side errors. If you know the specific problem, use a more specific code: 502 for bad gateway responses, 503 for temporary overload/maintenance, 504 for gateway timeouts. Reserve 500 for truly unexpected errors.
Ready-to-use code for returning this HTTP status in your application:
// Express.js
app.get('/example', (req, res) => {
res.status(500).json({
error: 'Internal Server Error',
message: 'Your error message here'
});
});
// Native HTTP
const http = require('http');
http.createServer((req, res) => {
res.writeHead(500, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
error: 'Internal Server Error',
message: 'Your error message here'
}));
}).listen(3000);- Unexpected server error with no more specific 5xx code applicable
- Unhandled exceptions or crashes in your application
- Generic catch-all for server-side failures
- Don't use for known issues - prefer 503 for maintenance, 502 for gateway issues
Indexing
Temporary 500 errors don't immediately de-index pages. Google retries and only drops pages after persistent failures over days/weeks.
Crawler Behavior
Crawlers back off and retry later when encountering 500 errors. Persistent 500s reduce your crawl budget.
Canonical URL Notes
Fix 500 errors quickly. If they persist, Google may drop the affected pages from the index entirely.
Google Notes
Google gives sites time to recover from 500 errors. Monitor Search Console for server errors and address them promptly.
500 Internal Server Error FAQ
What causes a 500 Internal Server Error error?
Unhandled exception in code. Database connection failed. Server misconfiguration.
When should I use 500 Internal Server Error?
Unexpected server error with no more specific 5xx code applicable. Unhandled exceptions or crashes in your application. Generic catch-all for server-side failures. Don't use for known issues - prefer 503 for maintenance, 502 for gateway issues.