Docker: Unable to connect to container from host

I try to use docker-compose in order to run an app which consists of 2 container: akka app and postgresql.
Here is yaml file:

version: "3"
    image: akka-app:latest
        - "9000:5000"
    image: postgres-db:latest

After the docker-compose up command I see that containers are up and running using docker ps command:

  • Installing an application into a docker containers through SSH
  • Calling docker commands from jenkins job as step running outside docker VM
  • Stop Solr gracefully when it running in docker
  • How to create a Docker container of an AngularJS app?
  • Image Name, Container Name in Docker Syslog Tag in Docker-Compose
  • udp traffic with Iperf for haproxy
  • CONTAINER ID        IMAGE                                COMMAND                  CREATED             STATUS              PORTS                    NAMES
    65326e5a9677        akka-app:latest                      "java -cp /..."   40 minutes ago      Up 23 seconds>5000/tcp   samplecompose_api_1
    1f86273c4f9a        postgres-db:latest                   "docker-ent..."   19 hours ago        Up 23 seconds       5432/tcp                 samplecompose_db_1

    But when I try to access the akka-app from the host via the GET request to or localhost:9000/status I get back “refused to connect” error in the postman.

    Extra information:

    • Docker version 17.06.0-ce, build 02c1d87
    • docker-compose version
    • 1.14.0, build c7bdf9e MacOS Sierra 10.12.5

    Network settings of the akka-app container:

    "NetworkSettings": {
        "Bridge": "",
        "SandboxID": "5b5b322ffb0fb881317f8cb4e69b8fd887566b8c5b73940174aabace35d816f8",
        "HairpinMode": false,
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "Ports": {
            "5000/tcp": [
                    "HostIp": "",
                    "HostPort": "9000"
        "SandboxKey": "/var/run/docker/netns/5b5b322ffb0f",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null,
        "EndpointID": "",
        "Gateway": "",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "IPAddress": "",
        "IPPrefixLen": 0,
        "IPv6Gateway": "",
        "MacAddress": "",
        "Networks": {
            "pinpointcompose_default": {
                "IPAMConfig": null,
                "Links": null,
                "Aliases": [
                "NetworkID": "925c8379c6d5b334177d7d198d1d38e29983903474183bee5734df9d30ab9810",
                "EndpointID": "c7c37f545b00c6a19863315858e93a79f10b54b5675dc2cb8704d2f2f9b2bb1c",
                "Gateway": "",
                "IPAddress": "",
                "IPPrefixLen": 16,
                "IPv6Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "MacAddress": "02:42:ac:12:00:02"


    docker-compose output:

    docker-compose up
    Starting samplecompose_api_1 ... 
    Starting samplecompose_api_1
    Starting samplecompose_db_1 ... 
    Starting samplecompose_api_1 ... done
    Attaching to samplecompose_db_1, samplecompose_api_1
    db_1   | LOG:  database system was shut down at 2017-07-06 08:54:56 UTC
    db_1   | LOG:  MultiXact member wraparound protections are now enabled
    api_1  | 09:04:26.030 [] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
    api_1  | 09:04:27.472 [] INFO sample-service - Bound to /

  • Running Xephyr inside a docker container
  • Docker-compose tries to execute multiple RUNs at once
  • `initialize': the scheme postgres does not accept registry part: postgres:@ (or bad hostname?) (URI::InvalidURIError) with Docker
  • sublime sftp connects to wrong container
  • Where to see the Dockerfile for a docker image?
  • Play framework auto-loading in docker container
  • One Solution collect form web for “Docker: Unable to connect to container from host”

    The problem was in an old VirtualBox installed who knows when on my laptop. So while it was installed I could not access running docker containers via localhost
    You can read more about this on official docker site

    After I uninstalled the VirtualBox from the laptop, then restarted the Docker app and relaunched the terminal sessions it was unreal to use localhost for access to the containers.

    Instead of the localhost I used the IP which I got from the docker-machine ip default. But this is not the good way.

    So ensure once again that you meet all of the requirements.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.