The 500 Internal Server Error is an HTTP status code indicating that the server encountered an unexpected condition and could not fulfill the request. It is a generic error message when no specific error details are exposed to the client.
HTTP response format for a 500 error:
// HTTP response indicating internal server failure
HTTP/1.1 500 Internal Server Error
Content-Type: text/html
// Example of a PHP script causing a 500 error due to fatal error
<?php
undefinedFunction();
?>
The server fails while executing backend code. Since the error is not handled, the server responds with a 500 status code instead of normal content.
Clicking the button below simulates a server failure response. We will visually simulate what happens in the Server Logs when this error occurs.
// Simulated server error using JavaScript
document.getElementById("failBtn").addEventListener("click", () => {
// Simulate server crash logs
printLog("[INFO] Incoming Request: GET /api/data");
printLog("[FATAL] Uncaught ReferenceError: db is not defined");
alert("500 Internal Server Error: Server crashed");
});