testcontainers-python
testcontainers-python copied to clipboard
could not translate host name "localnpipe" to address: Unknown host
venv\lib\site-packages\wrapt\wrappers.py:605: in __call__
return self._self_wrapper(self.__wrapped__, self._self_instance,
venv\lib\site-packages\testcontainers\core\waiting_utils.py:46: in wrapper
raise TimeoutException(
E testcontainers.core.exceptions.TimeoutException: Wait time exceeded 120 sec.
E Method _connect, args () , kwargs {}.
E Exception (psycopg2.OperationalError) could not translate host name "localnpipe" to address: Unknown host
E
E (Background on this error at: http://sqlalche.me/e/e3q8)
Please help me out with this thing.
@arpost, do you know whether this issue is related to the fix you added in #100?
I am experiencing the same issue on Windows 10. If I subclass PostgresContainer
like so then it works:
class X(PostgresContainer):
def get_connection_url(self):
return super().get_connection_url().replace('localnpipe', 'localhost')
with X('postgres:12.3') as pg:
print("HELLO")
engine = sqlalchemy.create_engine(pg.get_connection_url())
version, = engine.execute("select version()").fetchone()
print(version)
i.e. postgresql+psycopg2://test:test@localhost:32779/test
does work as the URL.
Some quick Googling suggests there are issues with Windows 10 and Docker named pipes but I can't honestly say they are the ultimate cause of this issue.
Perhaps DockerClient.host()
could be changed to return localhost
if the host is Windows 10? Happy to submit a patch for that but again I am not 100% that is the "right" thing to do.
I am experiencing the same issue on Windows 10. If I subclass
PostgresContainer
like so then it works:class X(PostgresContainer): def get_connection_url(self): return super().get_connection_url().replace('localnpipe', 'localhost') with X('postgres:12.3') as pg: print("HELLO") engine = sqlalchemy.create_engine(pg.get_connection_url()) version, = engine.execute("select version()").fetchone() print(version)
i.e.
postgresql+psycopg2://test:test@localhost:32779/test
does work as the URL.Some quick Googling suggests there are issues with Windows 10 and Docker named pipes but I can't honestly say they are the ultimate cause of this issue.
Perhaps
DockerClient.host()
could be changed to returnlocalhost
if the host is Windows 10? Happy to submit a patch for that but again I am not 100% that is the "right" thing to do.
Workaround also confirmed working on arch linux.
Another way to workaround the issue
# Monkey-patch the get_container_host_ip method
container.get_container_host_ip = lambda: 'localhost'
container.start()
I am experiencing the same issue on Windows 10. If I subclass
PostgresContainer
like so then it works:class X(PostgresContainer): def get_connection_url(self): return super().get_connection_url().replace('localnpipe', 'localhost') with X('postgres:12.3') as pg: print("HELLO") engine = sqlalchemy.create_engine(pg.get_connection_url()) version, = engine.execute("select version()").fetchone() print(version)
i.e.
postgresql+psycopg2://test:test@localhost:32779/test
does work as the URL.Some quick Googling suggests there are issues with Windows 10 and Docker named pipes but I can't honestly say they are the ultimate cause of this issue.
Perhaps
DockerClient.host()
could be changed to returnlocalhost
if the host is Windows 10? Happy to submit a patch for that but again I am not 100% that is the "right" thing to do.
This workaround works on Windows.
Any update on this issue ?
I also got an error running MysqlContainer on Windows because of the same error. If you do not assign TC_HOST value to localhost, it seems to bring docker host information to localnpipe. Why is the Docker client api adpaters information set to http+docker? I think this happened for a different purpose, but I'm curious as to why.
it seems to bring docker host information to localnpipe. Why is the Docker client api adpaters information set to http+docker? I think this happened for a different purpose, but I'm curious as to why.
it defined in docker-py https://github.com/docker/docker-py/blob/a48a5a9647761406d66e8271f19fab7fa0c5f582/docker/api/client.py#L168 but I don't understad why/
FYI there's some movement in docker-py and a new beta is available already: https://github.com/docker/docker-py/releases/tag/6.0.0b1
It has a lot of fixes related to dependencies and better Windows support
Same issue with localstack:
raise EndpointConnectionError(endpoint_url=request.url, error=e)
E botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://localnpipe:49162/test-bucket"
You can try this workaround:
os.environ['TC_HOST'] = 'localhost'