[Fixed]-Django.db.utils.InterfaceError: connection already closed failures when updating to Django 3.0

6👍

I ran into this as well. It appears to be a bug in pytest-django. Here’s the relevant issue. There’s an open PR to resolve it. If it’s a big enough inconvenience you can use the branch in that PR or pin your dependencies to an earlier version.

2👍

We were hitting the same issue, and upgrading from Django 3.0.2 to Django-3.0.4 resolved it. There are several DB related fixes in those two versions, but I don’t know which one solved our problem.

1👍

Just a forward note, it’s near impossible to provide more information than already is in the stacktrace. However, you can investigate:

  • Check when the connection get closed and by which test (run them individually via script for example).
  • For tests that fail, check the code for deprecated parts of Django (searching for things that were removed/deprecated between 2.3 and 3.0).
  • Run a linter to see if someone changed a private variable inside of Django framework as workaround.
  • Check the transactions of postgres.

Then once you have which part of the code has the error narrow it down by creating smaller failing tests.

0👍

I had the same issue using pytest.

Downgrading from 5.4.1 to 5.3.5 fixed it.

👤P4rk

0👍

All these issues occur because of the incompatibility of the other packages with django 3.0
when i ran into this error i updated my requirement.txt file manually and then intalled all the requirements using pip in the same env.

0👍

In my case I just forgot to run python manage.py makemigrations.

Leave a comment