1

I have been following Heroku's guide to getting started with Ruby on Heroku, and have gotten stuck trying to connect to the postgres database.

When I run:

bundle exec rake db:create db:migrate

I am left with this error:

could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

And:

Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"garrett", "username"=>"ruby-getting-started"}
could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

I have tried editing my database.yml file but I'm not sure if I am changing the correct parameters:

default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5

development:
<<: *default
database: ruby-getting-started_development
username: ruby-getting-started

test:
<<: *default
database: ruby-getting-started_test

production:
<<: *default
database: ruby-getting-started_production
username: ruby-getting-started
password: <%= ENV['RUBY-GETTING-STARTED_DATABASE_PASSWORD'] %>

Do I have my database.yml setup incorrectly or am I completely wrong?

4
  • try this command pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start , then do the db:migrate Commented Feb 2, 2015 at 2:08
  • Hey man, I tried running that command and ended up with this: garrett@garrett-virtual-machine:~/ruby-getting-started$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start pg_ctl: Coordinator or Datanode option not specified (-Z) Try "pg_ctl --help" for more information. Commented Feb 2, 2015 at 18:46
  • The Coordinator or Datanode option part of the message reveals that you don't have postgresql but postgres-xc. Presumably you've chosen the wrong packages at some point of your install. Ubuntu has an unfortunate error message when psql is not found that can lead to that mistake. Commented Feb 2, 2015 at 20:57
  • Thanks for the reply, Daniel. I removed Postgres-xc and ran: sudo apt-get install postgresql-9.3 Now, I receive this error after running bundle exec rake db:create db:migrate could not connect to server: no such file or directory Is the server running locally and accepting connections on unix domain socket "/var/run/postgresql/.s.PSQL.5432 Commented Feb 5, 2015 at 4:16

1 Answer 1

1

This is a common Postgres error that is basically telling you it can’t find the server. This can be caused by various reasons from not having it installed to a broken path from an OS update.

If you do have the server installed you could re install it through Homebrew or the GUI windows installer found at postgres.org.

Either way the fastest fix is to use a single package installer like Postgres.app for mac.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.