dokku / dokku-postgres

a postgres plugin for dokku
MIT License
484 stars 97 forks source link

How to connect to the second database in one application? #166

Closed afuno closed 5 years ago

afuno commented 5 years ago

I have an App1 application that has a connection to db1 database. I also have an App2 application that is connected to db2 database.

I need to make the App1 application have a second connection - with db2. That is, it could simultaneously work with two databases.

Now my application (application code) is ready for this. But the server is not ready. I get this error:

PG::ConnectionBad: could not translate host name "dokku-postgres-db2" to address: Name or service not known

This command does nothing:

dokku postgres:link db2 app1

How do I solve my problem?

josegonzalez commented 5 years ago

What is the output of:

dokku postgres:info db2
afuno commented 5 years ago

@josegonzalez

=====> Container Information
       Config dir:          /var/lib/dokku/services/postgres/db2/config
       Data dir:            /var/lib/dokku/services/postgres/db2/data
       Dsn:                 postgres://postgres:9493bb88ff654a6dd8c91d743d63a462@dokku-postgres-db2:5432/db2
       Exposed ports:       -
       Id:                  78a1c1f3bbc06363c26a3190e04e5a20956dd9532cd0a3a6416b5d3557b12302
       Internal ip:         172.17.0.9
       Links:               app2
       Service root:        /var/lib/dokku/services/postgres/db2
       Status:              running
       Version:             postgres:10.4
afuno commented 5 years ago

I re-created the connection. And the problem was solved. I apologise. Apparently I did something wrong the first time.