By Michal Hantl
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:
1. installed postgres
2. created database
3. linked my app
4. added rails_12factor to gemfile
5. 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?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
i have the same problem in ubuntun 16 rails one click …when i create a driplet the password of postgres
pg:connection:bad if a try to use the command rake db:migrate
Using the Precompile.ignore workaround I’ve been finally able to deploy my app.
Quoting the answer:
Add the following as /config/initializers/precompile.rb:
module Precompile
# Public: ignore the following block during rake assets:precompile
def self.ignore
unless ARGV.any? { |e| e == 'assets:precompile' }
yield
else
line = caller.first
puts "Ignoring line '#{line}' during precompile"
end
end
end
and use it in your routes.rb like this:
Precompile.ignore { ActiveAdmin.routes(self) }
Update: Problem is, the server starts, but still no connection :(
Update 2: Removing config/database.yml from git helped (I added it to see if it would help).
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.