2

I have a problem when running:

rake db:create:all

I currently have:

$ psql --version
psql (PostgreSQL) 9.3.0

$ which psql
/Applications/Postgres.app/Contents/MacOS/bin/psql

And get:

$ rake db:create:all
could not connect to server: Permission denied
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `initialize'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `new'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `connect'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:324:in `initialize'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
.....
.....

Tried to uninstall and re-install pg gem but still would not work.

First tried to follow Ryan Bates screencast but had some problems, and then checked the Heroku Postgres suggesting to set this path:

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

2
  • I used to have a similar problem. How did you install Postgresql? What does your database.yml look like? Commented Oct 8, 2013 at 11:49
  • thx for your reply. Downloaded on Postgres website. Tried to install it with homebrew following RyanBates screencast.. and using the same database.yml development: adapter: postgresql encoding: unicode database: blog_development pool: 5 username: blog password: Commented Oct 8, 2013 at 11:52

1 Answer 1

2

It could be that rake is trying to connect to /var/pgsql_socket/.s.PGSQL.5432 but the domain socket is actually somewhere else. Mine is at /tmp/.s.PGSQL.5432. You can try these:

Specify host: localhost in your database.yml. For example:

development:
  host: localhost
  # other stuff

OR

Create a symlink in /var/pgsql_socket/ to where .s.PGSQL.5432 actually lives.

mkdir /var/pgsql_socket
ln -s /tmp/.s.PGSQL.5432 /var/pgsql_socket/.s.PGSQL.5432

You'll probably have to chown and chmod the links too. I'm not sure if you have to link the .s.PGSQL.5432.lock as well.

The first option is a lot easier. Not sure if one or the other is better.

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

2 Comments

You must be right, when I run postgres and check \conninfo in the psql console I get: You are connected to database "stephanecedroni" as user "stephanecedroni" via socket in "/tmp" at port "5432" How would you change the domain socket like yours? Not sure how to create a symlink actually..Thx for your help
Try the host: localhost option first, that's much easier. Post back if you need more help.

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.