# Docker container cannot access postgres

**URL:** <https://forum.elixirforum.com/t/docker-container-cannot-access-postgres/34489>\
**Category:** Questions\
**Tags:** docker, phoenix\
**Created:** [September 21, 2020, 6:38am UTC](https://forum.elixirforum.com/t/docker-container-cannot-access-postgres/34489 "2020-09-21T06:38:41Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![jukvalim](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jukvalim/32/19199_2.png) [@jukvalim](https://forum.elixirforum.com/u/jukvalim)\
**Post date:** [September 21, 2020, 7:10am UTC](https://forum.elixirforum.com/t/docker-container-cannot-access-postgres/34489/4 "2020-09-21T07:10:35Z")

</div>

Docker containers run via docker-compose are not by default accessible to each other using “localhost” hostname, to reach a container from another container you need to use a hostname that is the [same as container name](https://docs.docker.com/compose/networking/). So you need to configure your database like this.

```elixir
username: "postgres",
password: "postgres",
database: "milk_dev",
hostname: "postgres",

```

Might be you also need to remove “hostname: localhost” from PostgreSQL service configuration.

---

_[View the full topic](https://forum.elixirforum.com/t/docker-container-cannot-access-postgres/34489)._
