5xx Server errors
HTTP 500 Internal Server Error
HTTP 500 Internal Server Error means the server hit an unexpected error and could not complete the request.
What 500 Internal Server Error means
A 500 is the generic "something broke on our side" answer, usually an unhandled exception. The client did nothing wrong and cannot fix it. Never send stack traces or database errors in the response body; log them on the server with a request id instead.
Common causes
- An unhandled exception or rejected promise in a route handler.
- A database query that throws (bad cast, lost connection).
- Code that reads a property of undefined.
How to fix or use it
Add one error-handling middleware that logs the error with a request id and returns a generic message. Map known errors (validation, not found, duplicate) to their own 4xx codes so 500 means a real bug.
Express (Node.js) example
app.use((err, req, res, _next) => {
logger.error({ err, requestId: req.id }, 'Unhandled error');
res.status(500).json({ message: 'Something went wrong', requestId: req.id });
});SEO impact
Occasional 500s are retried. Persistent 500s make Google crawl less and eventually drop the affected URLs. Monitor 5xx rates after every deploy.
