# Timeout when waiting for postgres:5432 psycopg2.OperationalError: could not translate host name "postgres" to address: Nam│ │127.0.0.1 | FAILED! "unable to connect to database: could not translate host name \\"postgres\\" to address: Name or service no

**URL:** <https://forum.ansible.com/t/timeout-when-waiting-for-postgres-5432-psycopg2-operationalerror-could-not-translate-host-name-postgres-to-address-nam-127-0-0-1-failed-unable-to-connect-to-database-could-not-translate-host-name-postgres-to-address-name-or-service-no/34073>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [October 21, 2020, 1:07pm UTC](https://forum.ansible.com/t/timeout-when-waiting-for-postgres-5432-psycopg2-operationalerror-could-not-translate-host-name-postgres-to-address-nam-127-0-0-1-failed-unable-to-connect-to-database-could-not-translate-host-name-postgres-to-address-name-or-service-no/34073 "2020-10-21T13:07:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roscha](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@Roscha](https://forum.ansible.com/u/Roscha)\
**Post date:** [October 21, 2020, 1:07pm UTC](https://forum.ansible.com/t/timeout-when-waiting-for-postgres-5432-psycopg2-operationalerror-could-not-translate-host-name-postgres-to-address-nam-127-0-0-1-failed-unable-to-connect-to-database-could-not-translate-host-name-postgres-to-address-name-or-service-no/34073/1 "2020-10-21T13:07:04Z")

</div>

macOS Docker Desktop

% docker --version  
Docker version 19.03.13, build 4484c46d9d

% ansible --version  
ansible 2.10.2  
config file = None  
configured module search path = [‘/Users/admin/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/local/lib/python3.8/site-packages/ansible  
executable location = /usr/local/bin/ansible  
python version = 3.8.6 (default, Oct 8 2020, 14:06:32) [Clang 12.0.0 (clang-1200.0.32.2)]

docker logs -f awx\_task

Using /etc/ansible/ansible.cfg as config file │  
│Using /etc/ansible/ansible.cfg as config file │  
│127.0.0.1 | FAILED! =\> { │  
│ “ansible\_facts”: { │  
│ “discovered\_interpreter\_python”: “/usr/libexec/platform-python” │  
│ }, │  
│ “changed”: false, │  
│ “elapsed”: 300, │  
│ “msg”: “Timeout when waiting for postgres:5432” │  
│} │  
│Using /etc/ansible/ansible.cfg as config file │  
│An exception occurred during task execution. To see the full traceback, use -vvv. The error was: psycopg2.OperationalError: could not translate host name “postgres” to address: Nam│  
│127.0.0.1 | FAILED! =\> { │  
│ “ansible\_facts”: { │  
│ “discovered\_interpreter\_python”: “/usr/libexec/platform-python” │  
│ }, │  
│ “changed”: false, │  
│ “msg”: “unable to connect to database: could not translate host name "postgres" to address: Name or service not known\n” │  
│} │  
│2020-10-21 11:05:17,620 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set│  
│2020-10-21 11:05:17,620 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set│  
│2020-10-21 11:05:17,927 INFO RPC interface ‘supervisor’ initialized │  
│2020-10-21 11:05:17,927 INFO RPC interface ‘supervisor’ initialized │  
│2020-10-21 11:05:17,927 CRIT Server ‘unix\_http\_server’ running without any HTTP authentication checking │  
│2020-10-21 11:05:17,927 CRIT Server ‘unix\_http\_server’ running without any HTTP authentication checking │  
│2020-10-21 11:05:17,928 INFO supervisord started with pid 103 │  
│2020-10-21 11:05:17,928 INFO supervisord started with pid 103 │  
│2020-10-21 11:05:18,931 INFO spawned: ‘awx-config-watcher’ with pid 106 │  
│2020-10-21 11:05:18,931 INFO spawned: ‘awx-config-watcher’ with pid 106 │  
│2020-10-21 11:05:18,935 INFO spawned: ‘dispatcher’ with pid 107 │  
│2020-10-21 11:05:18,935 INFO spawned: ‘dispatcher’ with pid 107 │  
│2020-10-21 11:05:18,938 INFO spawned: ‘callback-receiver’ with pid 108 │  
│2020-10-21 11:05:18,938 INFO spawned: ‘callback-receiver’ with pid 108 │  
│READY │  
│2020-10-21 11:05:20,041 INFO success: awx-config-watcher entered RUNNING state, process has stayed up for \> than 1 seconds (startsecs) │  
│2020-10-21 11:05:20,041 INFO success: awx-config-watcher entered RUNNING state, process has stayed up for \> than 1 seconds (startsecs) │  
│2020-10-21 11:05:20,041 INFO success: dispatcher entered RUNNING state, process has stayed up for \> than 1 seconds (startsecs

---

<div class="post-metadata">

**Author:** ![Roscha](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@Roscha](https://forum.ansible.com/u/Roscha)\
**Post date:** [October 21, 2020, 1:21pm UTC](https://forum.ansible.com/t/timeout-when-waiting-for-postgres-5432-psycopg2-operationalerror-could-not-translate-host-name-postgres-to-address-nam-127-0-0-1-failed-unable-to-connect-to-database-could-not-translate-host-name-postgres-to-address-name-or-service-no/34073/2 "2020-10-21T13:21:25Z")

</div>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/conf/settings.py”, line 80, in \_ctit\_db\_wrapper  
������  
yield  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/conf/settings.py”, line 418, in **getattr**  
value = self.\_get\_local(name)  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/conf/settings.py”, line 360, in \_get\_local  
setting = Setting.objects.filter(key=name, user\_\_isnull=True).order\_by(‘pk’).first()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/query.py”, line 653, in first  
for obj in (self if self.ordered else self.order\_by(‘pk’))[:1]:  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/query.py”, line 274, in **iter**  
self.\_fetch\_all()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/query.py”, line 1242, in \_fetch\_all  
self.\_result\_cache = list(self.\_iterable\_class(self))  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/query.py”, line 55, in **iter**  
results = compiler.execute\_sql(chunked\_fetch=self.chunked\_fetch, chunk\_size=self.chunk\_size)  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/sql/compiler.py”, line 1140, in execute\_sql  
cursor = self.connection.cursor()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 256, in cursor  
return self.\_cursor()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 233, in \_cursor  
self.ensure\_connection()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 217, in ensure\_connection  
self.connect()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/utils.py”, line 89, in **exit**  
raise dj\_exc\_value.with\_traceback(traceback) from exc\_value  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 217, in ensure\_connection  
self.connect()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 195, in connect  
self.connection = self.get\_new\_connection(conn\_params)  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/postgresql/base.py”, line 178, in get\_new\_connection  
connection = Database.connect(\*\*conn\_params)  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/psycopg2/ **init**.py”, line 126, in connect  
conn = \_connect(dsn, connection\_factory=connection\_factory, \*\*kwasync)  
django.db.utils.OperationalError: could not translate host name “postgres” to address: Name or service not known

2020-10-21 12:06:04,970 ERROR awx.conf.settings Database settings are not available, using defaults.  
Traceback (most recent call last):  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 217, in ensure\_connection  
self.connect()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 195, in connect  
self.connection = self.get\_new\_connection(conn\_params)  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/postgresql/base.py”, line 178, in get\_new\_connection  
connection = Database.connect(\*\*conn\_params)  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/psycopg2/ **init**.py”, line 126, in connect  
conn = \_connect(dsn, connection\_factory=connection\_factory, \*\*kwasync)  
psycopg2.OperationalError: could not translate host name “postgres” to address: Name or service not known

The above exception was the direct cause of the following exception:

Traceback (most recent call last):  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/conf/settings.py”, line 80, in \_ctit\_db\_wrapper  
������  
yield  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/conf/settings.py”, line 418, in **getattr**  
value = self.\_get\_local(name)  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/conf/settings.py”, line 360, in \_get\_local  
setting = Setting.objects.filter(key=name, user\_\_isnull=True).order\_by(‘pk’).first()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/query.py”, line 653, in first  
for obj in (self if self.ordered else self.order\_by(‘pk’))[:1]:  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/query.py”, line 274, in **iter**  
self.\_fetch\_all()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/query.py”, line 1242, in \_fetch\_all  
self.\_result\_cache = list(self.\_iterable\_class(self))  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/query.py”, line 55, in **iter**  
results = compiler.execute\_sql(chunked\_fetch=self.chunked\_fetch, chunk\_size=self.chunk\_size)  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/sql/compiler.py”, line 1140, in execute\_sql  
cursor = self.connection.cursor()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 256, in cursor  
return self.\_cursor()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 233, in \_cursor  
self.ensure\_connection()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 217, in ensure\_connection  
self.connect()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/utils.py”, line 89, in **exit**  
raise dj\_exc\_value.with\_traceback(traceback) from exc\_value  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 217, in ensure\_connection  
self.connect()  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 195, in connect  
self.connection = self.get\_new\_connection(conn\_params)  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/postgresql/base.py”, line 178, in get\_new\_connection  
connection = Database.connect(\*\*conn\_params)  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/psycopg2/ **init**.py”, line 126, in connect  
conn = \_connect(dsn, connection\_factory=connection\_factory, \*\*kwasync)  
django.db.utils.OperationalError: could not translate host name “postgres” to address: Name or service not known

2020-10-21 12:06:04,974 ERROR awx.conf.settings Database settings are not available, using defaults.  
Traceback (most recent call last):  
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 217, in ensure\_connection

среда, 21 октября 2020 г. в 16:07:04 UTC+3, Roscha:
