Question
Can't deploy Rails App, push fails (PG::ConnectionBad: could not connect to server: Connection refused)
Hi, after playing with DigitalOcean for a while I am setting up an instance for my customer and I am unable to push the app, because of database error.
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Which seems weird, since I bet the port is different on DO, but I don’t see how this can be if dokku/docker replaces the database.yml?
My database.yml is almost the same as on my other app which runs just fine.
development:
database: cttv
adapter: postgresql
user: michal
host: localhost
test: &test
database: cttv_test
adapter: postgresql
user: michal
host: localhost
production:
database: cttv
adapter: postgresql
user: michal
host: localhost
cucumber:
<<: *test
I think I did all the steps, but let me know if something is missing:
- installed postgres
- created database
- linked my app
- added rails_12factor to gemfile
- relinked the app with db to be sure with a script
Listing the processes reveal postgres should be running:
root@catchtalk:/var/lib/dokku/plugins# ps -ax | grep postg
4591 ? S 0:00 /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf
4593 ? Ss 0:00 postgres: checkpointer process
4594 ? Ss 0:00 postgres: writer process
4595 ? Ss 0:00 postgres: wal writer process
4596 ? Ss 0:00 postgres: autovacuum launcher process
4597 ? Ss 0:00 postgres: stats collector process
5990 ? S 0:00 su postgres sh -c /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf -c listen_addresses=*
5991 ? Ss 0:00 /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf -c listen_addresses=*
5993 ? Ss 0:00 postgres: checkpointer process
5994 ? Ss 0:00 postgres: writer process
5995 ? Ss 0:00 postgres: wal writer process
5996 ? Ss 0:00 postgres: autovacuum launcher process
5997 ? Ss 0:00 postgres: stats collector process
7059 pts/2 S+ 0:00 grep --color=auto postg
16895 ? S 0:00 su postgres sh -c /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf -c listen_addresses=*
16896 ? Ss 0:00 /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf -c listen_addresses=*
16898 ? Ss 0:00 postgres: checkpointer process
16899 ? Ss 0:00 postgres: writer process
16900 ? Ss 0:00 postgres: wal writer process
16901 ? Ss 0:00 postgres: autovacuum launcher process
16902 ? Ss 0:00 postgres: stats collector process
30751 ? S 0:00 su postgres sh -c /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf -c listen_addresses=*
30752 ? Ss 0:00 /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf -c listen_addresses=*
30754 ? Ss 0:00 postgres: checkpointer process
30755 ? Ss 0:00 postgres: writer process
30756 ? Ss 0:00 postgres: wal writer process
30757 ? Ss 0:00 postgres: autovacuum launcher process
30758 ? Ss 0:00 postgres: stats collector process
The app name is ‘dev’ since I want to see it on dev.mydomain.com, the pg logs:
root@catchtalk:/var/lib/dokku/plugins# dokku postgresql:logs dev
2014-11-04 06:27:47 UTC LOG: database system was interrupted; last known up at 2014-11-04 06:07:59 UTC
2014-11-04 06:27:47 UTC LOG: database system was not properly shut down; automatic recovery in progress
2014-11-04 06:27:47 UTC LOG: record with zero length at 0/1782E70
2014-11-04 06:27:47 UTC LOG: redo is not required
2014-11-04 06:27:47 UTC LOG: database system is ready to accept connections
2014-11-04 06:27:47 UTC LOG: autovacuum launcher started
One thing I know is different though is that I have set only the A record of dev.myserver.com
, not the myserver.com
itself, since there is still the old app running on heroku which I’ll then want to switch to DO, when the deploy is successful.
But that shouldn’t affect anything, right?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×