Troubleshooting

500 Internal Server Error

Reviewed on 2 min read errores http servidor

Description of the problem

When I access my website or a file, the browser shows an error message headed "500 Internal Server Error".

Get the exact error

The 500 code doesn't identify the cause. Reproduce a single request and note down the URL and time. Then check cPanel > Errors and the PHP and application logs for that same moment. Don't turn on public error display on a production website.

Follow the branch that matches the logged message:

.htaccess

If the log mentions a directive that isn't allowed or a syntax error, fix the exact line in .htaccess. Don't rename or empty the whole file without keeping a copy, because it may contain security and application rules.

PHP or application

If a fatal error, an exception, exhausted memory or maximum execution time exceeded appears, use the message, the stack trace and the line shown to find the cause; that line may just be where the failure surfaced. A loop can end up as a 500, a 503 or a timeout depending on the environment; the HTTP code doesn't prove it on its own.

Permissions / chmod

On Hostsuar, normally use 755 for directories and 644 for files. 777 permissions are insecure, but only blame the 500 on permissions when the log shows a denial or a handler requirement. Also check the owner and traversal permissions of the parent directories.

If it started after a change

Link the first failure to an update, a PHP change or a deployment. Keep the previous file and configuration and test one fix at a time. Going back to a database backup may remove recent orders or changes: don't use it as a substitute for finding a faulty line.

Don't apply chmod recursively to the whole account; some private files need more restrictive permissions. Once you have fixed the cause, test the original URL and the operation that was failing, not just the home page. If you can't find a matching log entry, give support the time with time zone, the URL and the steps, without publishing stack traces that contain credentials or personal data.

You may also find useful

Something wrong or out of date? Tell us and we will review it.