Could not translate host name "postgres" to address

I am trying to apply migration using this command “docker-compose run --rm server manage db upgrade” but got this error :

File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 2102, in connect
return self._connection_cls(self, **kwargs)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 90, in init
if connection is not None else engine.raw_connection()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 2188, in raw_connection
self.pool.unique_connection, _connection)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 2162, in _wrap_pool_connect
e, dialect, self)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 1476, in _handle_dbapi_exception_noconnection
exc_info
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py”, line 265, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 2158, in _wrap_pool_connect
return fn()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 342, in unique_connection
return _ConnectionFairy._checkout(self)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 788, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 529, in checkout
rec = pool._do_get()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 1284, in _do_get
return self._create_connection()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 347, in _create_connection
return _ConnectionRecord(self)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 474, in init
self.__connect(first_connect_check=True)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 671, in __connect
connection = pool._invoke_creator(self)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py”, line 106, in connect
return dialect.connect(*cargs, **cparams)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py”, line 412, in connect
return self.dbapi.connect(*cargs, **cparams)
File “/usr/local/lib/python2.7/site-packages/psycopg2/init.py”, line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name “postgres” to address: Temporary failure in name resolution

1 Like

Seems like a DNS lookup error.

I cannot find reason of this error do you have any idea about how it occurred or Do you have an solution ?

I exactly have the same problem. trying to install locally on my mac using production’s docker-compose.yml resulting in the same could not translate host name “postgres” error.

Hi, I just found the solution for this issue, it might be a result of PostgreSQL release that requires users to use the password. I found it here postgres auth method, you can add those line in the environment variable (if your prior postgres were set without password)

1 Like