Can`t run `manage.py test` in Django: django.db.utils.OperationalError

Question:

I`m trying to run some auto-tests in Django framework 4.0.4 by command

python manage.py test test.to.run

Also at the start it gets notification:

RuntimeWarning: Normally Django will use a connection to the 'postgres' database to avoid running initialization queries against the production database when it's not needed (for example, when running tests). Django was unable to create a connection to the 'postgres' database and will use the first PostgreSQL database instead.

, but at the result it gets error without any specific explanation:

...conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError
    
The above exception was the direct cause of the following exception:
...
conn = _connect(dsn, connection_factory=connection_factory,
    **kwasync) django.db.utils.OperationalError

Connected DB is postgres located on another computer in the local network.

When I run app on dev-server by command

python manage.py runserver

everything goes ok, there are no troubles with database.

I tried to create local postgres database on my machine and set connection to it in settings.py, python manage.py test runs as well too.

Asked By: meshi

||

Answers:

It was necessary to add a connection to my machine in pg_hba.conf

Answered By: meshi
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.