3

follow the screencasts http://railscasts.com/episodes/342-migrating-to-postgresql?autoplay=true up to the steps of "rake db:create:all" and get error:

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

refer the question on Rails: rake db:create:all fails to connect to PostgreSQL database

but still unable to resolve it. Not sure what is the problem. enter image description here

[database.yml]

development:
  adapter: postgresql
  encoding: unicode
  database: store_development
  pool: 5
  username: amysukumunu 
  password:
test:
  adapter: postgresql
  encoding: unicode
  database: store_test
  pool: 5
  username: amysukumunu
  password: 
Community
  • 1
  • 1
shoujo_sm
  • 3,173
  • 4
  • 37
  • 60

1 Answers1

4

[update2]

okay, This is what you should do:

  1. the unix socket should be at /var/pgsql_socket(as per the plist image) where as rails is trying to find the socket file in /tmp. I believe this is the reason for error. so Edit your database.yml & explicitly add socket location. so your final database.yml should look like this. change the file location for your unix socket location. try to connection now?

2) If it still doesn't connect. verify that postgres server is actually running

$ netstat -a | grep postgre

if its running, try connecting to it from terminal using psql command. incase its, not running. try starting it manually

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

If it still doesn't start, Are there any error messages in the server.log? If yes do post them here.

Good luck! =======UPDATED=============== enter image description here enter image description here

CuriousMind
  • 33,537
  • 28
  • 98
  • 137
  • it my finder don't have the file "postgresql.conf". 0items. what is the template1 means? id it my app name? – shoujo_sm May 07 '12 at 23:50
  • template1 is the default database on postgressql but it looks like its different on mac(no postgresql.conf?), so try following the updated troubleshooting instructions. – CuriousMind May 09 '12 at 07:07
  • it's say dont have "org.postgresql.postgres.plist" on the second command – shoujo_sm May 09 '12 at 23:41
  • Well, you can try listing all files `ls -R /usr/local/Cellar/postgresql/` & see if plist is present. if yes, then try to copy that plist to `~/Library/LaunchAgents` & then, proceed to next command. Hope it helps – CuriousMind May 10 '12 at 04:54
  • 1
    I updated the image of the plist I find online and copy it into launchAgents and execute the second command but get "cp: /usr/local/Cellar/postgresql/9.0.1/org.postgresql.postgres.plist: No such file or directory " – shoujo_sm May 11 '12 at 12:52
  • Alright, I have updated my answer. try it, see if it works for you – CuriousMind May 15 '12 at 10:23
  • Thanks... It shows "server starting." Is this means it finally ok? – shoujo_sm May 20 '12 at 00:46
  • Yes, It Should be. are you still not able to connect? – CuriousMind May 20 '12 at 08:18