Django InterfaceError: Connection already closed
May 17, 2024
Background # Stack: gunicorn + Django + pyscopg2 Error InterfaceError: Connection already closed started appearing after performing new deploys of the application. These errors would appear from multiple gunicorn workers at the same time some 60 seconds after the workers would initialize. Understanding the stacktrace # The error indicates that when Django ORM attempted to perform an SQL query through an open Psycopg2 connection, the connection was already closed. Django tries to execute the query through the assumed open connection, but when it is closed, the error occurs. ...