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/”, line 2102, in connect
return self._connection_cls(self, **kwargs)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/”, line 90, in init
if connection is not None else engine.raw_connection()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/”, line 2188, in raw_connection
self.pool.unique_connection, _connection)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/”, line 2162, in _wrap_pool_connect
e, dialect, self)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/”, line 1476, in _handle_dbapi_exception_noconnection
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/util/”, 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/”, line 2158, in _wrap_pool_connect
return fn()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/”, line 342, in unique_connection
return _ConnectionFairy._checkout(self)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/”, line 788, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/”, line 529, in checkout
rec = pool._do_get()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/”, line 1284, in _do_get
return self._create_connection()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/”, line 347, in _create_connection
return _ConnectionRecord(self)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/”, line 474, in init
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/”, line 671, in __connect
connection = pool._invoke_creator(self)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/”, line 106, in connect
return dialect.connect(*cargs, **cparams)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/”, line 412, in connect
return self.dbapi.connect(*cargs, **cparams)
File “/usr/local/lib/python2.7/site-packages/psycopg2/”, 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