A 500 Error with an Error Reference (Pro)

The application shows an error page with:

HTTP ERROR 500
Internal Server Error
The server encountered an internal error.
Error reference: 3f2b9c6e0d4a4f1e9b7c5a2d8e6f1c0b

and the API call behind it answered 500 with this body:

{"message": "Internal server error, check logs for details", "error_reference": "3f2b9c6e0d4a4f1e9b7c5a2d8e6f1c0b"}

The error page appears when the failed call was the one loading the page. A call that fails inside a page that is already open shows a Server Error notification instead, and the reference is only in the API body (the browser’s Network tab shows it). The error page shows the reference from DefectDojo 3.5.201.

When there is a reference

The reference is 32 hexadecimal characters, different for each failed request. The server adds it only when automatic error reports are on, and it is the key DefectDojo support uses to find the report the server sent for this failure. Quote it when you contact support.

On a self-hosted instance those reports are off by default, and an air-gapped instance never sends them, so a 500 there usually has no reference at all. Use the time of the failure to find it in the logs instead.

Find the failure in the logs

The web container that served the request logs the failure with its traceback, on a line that starts with Internal Server Error: and the request path, for example Internal Server Error: /api/v2/findings/. With error reports on, the Celery worker also logs a line with the reference when it relays the report:

error diagnostics: relayed backend-api report (ref=3f2b9c6e0d4a4f1e9b7c5a2d8e6f1c0b)

Search the worker’s log for the reference to find the time of the failure, then read the web container’s log at that time.

Docker Compose:

docker logs --timestamps celeryworker 2>&1 | grep "ref=3f2b9c6e0d4a4f1e9b7c5a2d8e6f1c0b"
docker logs --timestamps dojo 2>&1 | grep -A40 "Internal Server Error:"

Kubernetes:

kubectl logs -n <namespace> -l app.kubernetes.io/component=celery --all-containers --timestamps --tail=-1 | grep "ref=3f2b9c6e0d4a4f1e9b7c5a2d8e6f1c0b"
kubectl logs -n <namespace> -l app.kubernetes.io/component=django --all-containers --timestamps --tail=-1 | grep -A40 "Internal Server Error:"

A scan import is served by its own web container when the deployment runs one: dojo-import-scan on Docker Compose, the django-import component on Kubernetes. Search that log too for a failed import.

Fix

The fix depends on the traceback. If it does not point to your configuration, contact DefectDojo support with:

  • the error reference, if there is one;
  • the time of the failure and the page or API call that failed;
  • the traceback from the log.