Skip to content

500 Internal Server Error explained: causes and fixes

By the ProxyOnly team · 16 Nov 2026 · 6 min read

A 500 is the server's catch-all for an unexpected failure. What causes it, how to find the cause in the logs, and what to do as a visitor, a site owner or a script.

A 500 Internal Server Error means that the server hit an unexpected condition and could not fulfil your request. That is the whole definition in RFC 9110, and it is deliberately vague. The server knows more than it says, because the details belong in a log and not on a public page.

The useful fact is where the problem is: on the server, in the code or the configuration that handles your request. Nothing you typed made the server fail by itself, although some inputs can trigger a bug that was already there. This article explains the common causes, how to find the real one, and what to do whether you are a visitor, the owner of the site or a script.

How a 500 differs from nearby errors

  • 500 Internal Server Error: the server software or the application failed while it was handling the request.
  • 501 Not Implemented: the server does not support what the request needs, for example an unknown request method. It is rare.
  • 502 Bad Gateway, 503 Service Unavailable and 504 Gateway Timeout: something the server depends on failed, is busy or was too slow. See 502, 503 and 504.

A simple way to remember it: a 500 says "I broke", and the others say "something I rely on is broken, busy or slow".

See it happen

We wrote two small servers that both crash on a request for /boom. One is a WSGI application, the interface that Python web frameworks use. The other is a bare HTTP handler with no framework around it.

import http.server, threading, wsgiref.simple_server
def app(environ, start_response):
    if environ["PATH_INFO"] == "/boom":
        return [str(1 / 0).encode()]
    start_response("200 OK", [("Content-Type", "text/plain")])
    return [b"fine"]
class Bare(http.server.BaseHTTPRequestHandler):
    def do_GET(self):
        raise RuntimeError("bug in the handler")
wsgi = wsgiref.simple_server.make_server("127.0.0.1", 9300, app)
threading.Thread(target=wsgi.serve_forever, daemon=True).start()
http.server.HTTPServer(("127.0.0.1", 9301), Bare).serve_forever()

We requested /boom from each with curl. The output is trimmed to the lines that matter:

$ curl -si http://127.0.0.1:9300/boom
HTTP/1.0 500 Internal Server Error
Content-Type: text/plain
A server error occurred.  Please contact the administrator.
$ curl -sS http://127.0.0.1:9301/boom
curl: (52) Empty reply from server

The two servers failed in the same way and the visitor saw something different. The WSGI layer caught the exception and turned it into a proper 500. The bare handler had nobody to catch it, so the connection simply closed, and curl reported "Empty reply from server". If a gateway had stood in front of that second server, it would have turned the empty reply into a 502, as we showed in the 502 article.

The cause is in the server's log, not in the response. Ours printed ZeroDivisionError: division by zero for the first request and RuntimeError: bug in the handler for the second. That is what you look for first when your own site returns a 500.

Common causes

In the application:

  • An unhandled exception in the code, such as the one above. After a deployment this is the most likely cause.
  • Input that the code did not expect, for example a missing field or a number that is far too large.
  • A dependency, a setting or an environment variable that is missing or has a different version after a change.

In the server configuration:

  • A syntax error in an Apache .htaccess file or configuration. Apache's source contains the message "Invalid command" followed by the name of the directive and "perhaps misspelled or defined by a module not included in the server configuration".
  • A loop in nginx rewrite rules. nginx logs rewrite or internal redirection cycle while processing and answers with a 500.
  • A script without permission to run, or an application that cannot write to a folder it needs.

In the resources around it:

  • A PHP script that exceeds its memory limit, or a full disk.
  • A database that is down or has no free connections. Cloudflare's documentation names "Error establishing a database connection" as a common cause of 500 errors.
  • A call to a third-party service that fails and is not handled.

If you are a visitor

  1. Reload once after a minute. A 500 caused by a bad deployment is often fixed quickly.
  2. Go back and try another page of the same site. If only one page fails, the bug is probably in that page.
  3. If it happened when you submitted a form or paid, check before you try again. The server may have completed part of the action before it failed.
  4. Tell the site's owner if it lasts. Include the page, the time and what you did.

If you run the site

  1. Read the logs first. Look in the web server's error log, the application's log and the PHP error log if you use PHP, at the time of the request. The real error is there.
  2. Reproduce it with curl -i against the same URL, with the same method and data, so that you can test a fix without a browser.
  3. Ask what changed: a deployment, a plugin update, a configuration edit, a new PHP version, an expired credential for an outside service, a full disk.
  4. Roll back to the last working version if you can, and then fix the problem calmly on a copy.
  5. Make failures visible. Use an error tracker or an alert on the number of 5xx responses, so that you hear about a 500 before a visitor tells you. Also keep details out of the public page and show a friendly error instead, because stack traces help attackers.
  6. Remember search engines. Google's documentation on HTTP status codes says that 500 errors make its crawler slow down, and that URLs that persistently return a server error are removed from the index.

For WordPress, the official documentation lists what to try. The most likely cause is a corrupted .htaccess file, so rename it to .htaccess_old and reload the site. If that works, reset the permalinks in the settings to generate a new one. After that, deactivate all plugins, switch to a default theme, increase the PHP memory limit, and as a last step re-upload the wp-admin and wp-includes folders from a fresh copy.

Behind Cloudflare, read the error page. Cloudflare's documentation for error 500 says that if the page contains "cloudflare" or "cloudflare-nginx", you should contact Cloudflare Support with your domain, the time and timezone of the error and the output of /cdn-cgi/trace. If it does not, the 500 comes from your own server, and you should start with the logs.

If a script or scraper gets a 500

  • A 500 usually means the server failed on your request. Open the same URL in a browser. If it fails there too, the site is broken and nothing on your side will fix it.
  • Look at what you sent. Strange query strings, enormous page numbers and malformed parameters can trigger bugs, so try a simpler request.
  • Retry a few times with growing waits, because some 500s are temporary. The article on 503 Service Unavailable shows a retry setup that does this safely. Stop after a fixed number of attempts and record the URL and the time.
  • If many different URLs start returning 500 at once, the site is struggling. Slow down instead of speeding up. Rate limiting for scrapers explains how to find a pace a site can handle.
  • Do not read a 500 as a block. Refusals normally arrive as a 403 or a 429, and why websites block IPs and proxies explains how to tell them apart.

Try it yourself

Create an account, add funds from US$1 and order a proxy in the country you need.

Keep reading