# Accessing to the database from outside the container

**URL:** <https://meta.discourse.org/t/accessing-to-the-database-from-outside-the-container/45257>\
**Category:** Self-hosting\
**Created:** [June 4, 2016, 7:25pm UTC](https://meta.discourse.org/t/accessing-to-the-database-from-outside-the-container/45257 "2016-06-04T19:25:40Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Chopper](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chopper/32/57073_2.png) [@Chopper](https://meta.discourse.org/u/Chopper)\
**Post date:** [June 4, 2016, 7:25pm UTC](https://meta.discourse.org/t/accessing-to-the-database-from-outside-the-container/45257/1 "2016-06-04T19:25:40Z")

</div>

How can i access to the database from ouside the container but in the same server (local)

I open the port in app.yml

```
expose:
  - "4002:5432" #postgres

```

Try to connect from outside with

```plaintext
psql -h 127.17.0.1 -p 4002 -d postgres -U postgres -p ''
psql: could not connect to server: Connection refused
        Is the server running on host "127.17.0.1" and accepting
        TCP/IP connections on port 5432?

```

What i’m missing ?

---

_[View the full topic](https://meta.discourse.org/t/accessing-to-the-database-from-outside-the-container/45257)._
