Skip to content
500

Internal Server Error

Server Error (5xx)

The 500 Internal Server Error status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request. It is a generic catch-all for server-side errors that do not fit a more specific 5xx code. The error is on the server side, not the client. Check server logs for the actual error details.

What is HTTP 500 Internal Server Error?

HTTP 500 Internal Server Error is a server error (5xx) status code. The 500 Internal Server Error status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request. It is a generic catch-all for server-side errors that do not fit a more specific 5xx code. The error is on the server side, not the client. Check server logs for the actual error details. Common causes include unhandled exception in application code and database connection failure. To fix it, check server logs for the actual error message and stack trace.

Example Response

HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{"error": "An unexpected error occurred"}

Common Causes

How to Fix

  1. 1. Check server logs for the actual error message and stack trace
  2. 2. Verify database connections and credentials
  3. 3. Review recent code deployments for regressions
  4. 4. Check server resource usage (memory, disk, CPU)
  5. 5. Test the endpoint in a development environment

Frequently Asked Questions

How do I debug a 500 error?

Start with the server logs — they contain the actual error. Check application logs, web server error logs (nginx/Apache), and system logs. In development, enable stack traces in error responses. In production, use error monitoring tools like Sentry.

Is a 500 error always the server's fault?

Yes, by definition. 500 indicates a server-side issue. If the problem is with the client's request, the server should return a 4xx error instead. However, a poorly written server might return 500 for what should be a 400.

Should I show error details to users?

Never expose internal error details (stack traces, database queries) in production. Return a generic error message to clients and log the details server-side. Exposing internals is a security risk.

Related Status Codes

502 Bad Gateway 503 Service Unavailable 504 Gateway Timeout

Related Reading

HTTP Status Codes Cheat Sheet: Every Code Explained → JSON vs YAML vs TOML: Which Config Format to Use →