9

I'm using MacOSX Lion, ruby 1.9.2, Rails 3.1.2 and postgres 9.0.4

I did a rake db:migrate on my app using postgres. It failed with access denied error.

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
rake aborted!
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"?

I have checked whether server is running and it is running ok. I could connect successfully to my db using

psql -Umyuser myapp_development
psql -Umyuser myapp_test

While creating a new PG user, it never asked me for a password and so I didn't give password for that user myuser anywhere.

Here is my database.yml file.

development:
  adapter: postgresql
  encoding: utf8
  database: myapp_development
  username: pgguy

test:
  adapter: postgresql
  encoding: utf8
  database: myapp_test
  username: pgguy

production:
  adapter: postgresql
  encoding: utf8
  database: myapp_production

what should I do to connect to it from my rails app?

1 Answer 1

24

Adding host to my database.yml file solved this.

development:
  adapter: postgresql
  encoding: utf8
  database: myapp_development
  username: myuser
  host: localhost

test:
  adapter: postgresql
  encoding: utf8
  database: myapp_test
  username: myuser
  host: localhost

production:
  adapter: postgresql
  encoding: utf8
  database: myapp_production

I referred to this thread for a solution: Repairing Postgresql after upgrading to OSX 10.7 Lion

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

2 Comments

thank you so much! i've been trying to diagnose this for hours.
Excellent! .. Spent one day trying to solve this in OS X 10.8.1. Thank you!

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.