Failed to load resource: the server responded with a status of 500 (Internal Server Error):

This website has been deployed for some time. I get the above error when trying to submit a form using htmx (POST request). The form has been working correctly for months and I made no changes at all between the last time it was working and now so I am at a loss of where to look. I tested it locally and it is working fine. Any pointers would be much appreciated.

Check your log files for the server. (Both the web server and the wsgi container.)

Also, if you have your server configured for this, it will send an email to an administrator for every 500 error generated with lots of detail. Check to see where those emails are being sent.

I am using Nginx and Gunicorn.

For Nginx: *39 upstream prematurely closed connection while reading response header from upstream

sudo nginx -t is not reporting any problems

Gunicorn isn’t reporting any errors.

I am yet to configure the django app to send error reports by email but I will be definitely looking into after this.

Check syslog, check application logs, check the nginx logs. Check for both access and error logs. If you’re using docker, check the container logs. There’s going to be a trail of information somewhere - and where that “somewhere” is will depend upon your precise configuration.

I had already checked the nginx logs. I would have never thought to check the syslog but it is showing errors related to gunicorn.

[1319643] [CRITICAL] WORKER TIMEOUT (pid:1319735)

[1319735] [ERROR] Error handling request ( the post request)

I am not sure exactly what that means but at least it is a start.