Skip to content

could not translate host name "localnpipe" to address: Unknown host #108

Open

Description

@dbaskarraj
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.

Activity

  1. tillahoffmann commented on Jul 6, 2020

    @tillahoffmann
    Contributor

    @arpost, do you know whether this issue is related to the fix you added in #100?

  2. petedmarsh commented on Jul 17, 2020

    @petedmarsh

    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.

  3. greg-el commented on Jul 17, 2020

    @greg-el

    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.

    Workaround also confirmed working on arch linux.

  4. arcann commented on Jan 27, 2021

    @arcann

    Another way to workaround the issue

    # Monkey-patch the get_container_host_ip method
    container.get_container_host_ip = lambda: 'localhost'
    container.start()
    
  5. marcrleonard commented on Mar 18, 2021

    @marcrleonard

    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.

    This workaround works on Windows.

  6. vinchauhan commented on May 5, 2021

    @vinchauhan

    Any update on this issue ?

  7. ujkim commented on Aug 8, 2021

    @ujkim

    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.

  8. bomzheg commented on Jan 14, 2022

    @bomzheg

    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/

  9. xSAVIKx commented on Jul 30, 2022

    @xSAVIKx

    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

  10. dwwhitlock commented on Apr 4, 2023

    @dwwhitlock

    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"
    
  11. YouJiacheng commented on May 9, 2023

    @YouJiacheng

    You can try this workaround:

    os.environ['TC_HOST'] = 'localhost'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions