Kloadut / dokku-pg-plugin

PostgreSQL plugin for Dokku
201 stars 75 forks source link

could not connect to server: Connection refused #40

Open stevenjwolfman opened 10 years ago

stevenjwolfman commented 10 years ago
   Is the server running on host "127.0.0.1" and accepting
   TCP/IP connections on port 5432?
   (PG::ConnectionBad)

No matter what I did including setting the ENV file, I couldn't get away from this problem when trying to deploy my app on digital ocean?
I'm trying to install ruby 2.1.1 I started with the premade digital ocean dokku image. I don't know whats causing it and although I saw some reference to this problem in the first comment on https://www.digitalocean.com/community/articles/how-to-use-the-dokku-one-click-digitalocean-image-to-run-a-ruby-on-rails-app I couldn't find a solution to this problem that worked for me

stevenjwolfman commented 10 years ago

This is definitely a ruby 2.1.1 issue because I didn't have this problem when I pushed my other app that is 2.0.0

hellojere commented 10 years ago

+1

dommmel commented 10 years ago

In my case the plugin confuses Gateway with IPAddress and uses the HostPort instead of the guest's. Correcting the resp. config variables solves the issue.

sangyongjung commented 10 years ago

@dommmel I think I am suffering from the same issue. Can you inform me how to correct the resp. config variable(?)? Thanks in advance. :)

sangyongjung commented 10 years ago

@stevenjwolfman I am using ruby 2.0.0 and still have the same problem.. don't even known what triggered this problem.. orz

dommmel commented 10 years ago

@stevenjwolfman in my case my apps DATABASE_URL was wrong. (You can inspect that variable via dokku config your_app_name | grep DATABASE_URL)

It had the form postgres://root:gibberish_password@172.17.42.1:49153/db where it should have postgres://root:gibberish_password@172.17.0.86:5432/db

I got the correct IP and PORT by running docker inpect <postegres_container_id> and looking for IPAddressand ExposedPort. You can then set the new DATABASE_URL via dokku config:set your_app_name DATABASE_URL=

Hope that helps

sangyongjung commented 10 years ago

@dommmel @stevenjwolfman I solved mine. In my case, it was due to a filter I added to active admin.

In active admin I added a function call requires pg connection, and it caused the app trying to connect to DB while precompiling assets.

Looking for gems that try to connect to DB may help.

dommmel commented 10 years ago

@sangyongjung dokku-user-env-compile might help with that as well.

sangyongjung commented 10 years ago

@dommmel Oh, this one is cool, I'll try that later since I just removed the function call that caused the prob. Thanks! :D

cameron-martin commented 10 years ago

@dommmel Thanks, this solved my problem too. I'll send a PR fixing this tomorrow.

cameron-martin commented 10 years ago

Hmm, the ip address doesn't seem to be static though, it changes under certain circumstances (not sure when, but it just changed for me when I did some admin, including a reboot and rebuild of buildstep).

Anyone got any insight into how to make this static?

rchrd2 commented 9 years ago

I can confirm that the environment variable was not set correctly. I had to inspect the postgres container with docker (docker inspect bd27dfdb8b3f) and then change the config value with dokku.

dokku config:set django-example DATABASE_URL=postgres://root:gibberish@172.17.42.1:49161:/db

dokku version = v0.3.12 ubuntu version = Linux digital-lair 3.13.0-32-generic #57~precise1-Ubuntu SMP Tue Jul 15 03:51:20 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

aldoforce commented 9 years ago

Same issue here running dokku v0.3.17 on ubuntu 14.04 at Digital Ocean. When using: dokku postgresql:link api api

The generated DATABASE_URL was not correct. It's using the Gateway and not the IPAddress (nor port)

@dommmel solution works fine, you need to update the DATABASE_URL manually.