1
Exiting
/Users/judyngai/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record    /connection_adapters/postgresql_adapter.rb:1216:in `initialize': could not connect to          server: No such file or directory (PG::Error)
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

I read through some posts, somebody suggest adding

host: localhost

to the database.yml file

and then I got this new error

Exiting
/Users/judyngai/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record        /connection_adapters/postgresql_adapter.rb:1216:in `initialize':      could not connect to server: Connection refused (PG::Error)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

can somebody point me to the right direction?

I don't think I have given enough information

when I do

psql --version
psql (PostgreSQL) 9.2.4

which psql 
/usr/local/bin/psql

I do have psql installed on my machine

and here is my database.yml file

test:
  adapter: postgresql
  encoding: unicode
  database: pinny_test
  pool: 5
  username: judyngai
  password:
  host: localhost

development:
  adapter: postgresql
  encoding: unicode
  database: pinny_development
  pool: 5
  username: judyngai
  password:
  host: localhost

I uncommented out the production part.

Jngai1297
  • 2,415
  • 5
  • 29
  • 63

2 Answers2

1

It seems that you have misconfiguration of PostgreSQL. You need to change the configuration in pg_hba.conf. You can see this answer https://stackoverflow.com/a/7696398/1405852

Community
  • 1
  • 1
Blue Smith
  • 8,580
  • 2
  • 28
  • 33
  • Hi I actually don't have /etc/postgresql/8.4/main/pg_hba.conf in my machine, I use 9.2.4 but I still don't have /etc/postgresql – Jngai1297 May 14 '13 at 22:06
  • If you're using Mac, the file can be in /Library/PostgreSQL/9.2/data/pg_hba.conf. You must have `sudo` right to access the file. You can try in the terminal: sudo bash, cd /Library/PostgreSQL/9.2/data/, nano pg_hba.conf – Blue Smith May 15 '13 at 04:02
0

I'm assuming your database.yml file looks something like this:

development:
  adapter: postgresql
  database: app_development
  host: localhost

test:
  adapter: postgresql
  database: app_test
  host: localhost

production:
  adapter: postgresql
  database: app_production
  host: localhost

You need to have the Postgres App installed and running. Here's the documentation.

Let me know if you still have issues.

vich
  • 11,836
  • 13
  • 49
  • 66
  • Hello I do have postgresql installed, I used this railscast video – Jngai1297 May 14 '13 at 21:48
  • Are you running PG before starting the rails server? When I open the PG app (elephant icon) I can see it says `Running on Port 5432` which looks like what your error is referencing. – vich May 14 '13 at 22:08