Reputation: 7835
I've looked here and here but still can't solve my problem. I have my setup working perfectly on my normal linux but when I tried to recreate it on my mac postgres won't work with rails. After following these instructions from railscasts I get to the point where I run rake:db:create:all
running rake db:create:all:
$ rake db:create:all --
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
but running psql works fine:
$ psql
psql (9.3.1)
Type "help" for help.
crashandburn4=#
checking which port postgres is running on yields:
$ cat /etc/services |grep post
postgresql 5432/udp # PostgreSQL Database
postgresql 5432/tcp # PostgreSQL Database
so it doesn't appear to be an incorrect port and my database.yml explicitely states the port:
# database.yml
development:
adapter: postgresql
encoding: unicode
database: blog_development
pool: 5
username: myusername
password:
port: 5432
test:
adapter: postgresql
encoding: unicode
database: blog_test
pool: 5
username: myusername
password:
port: 5432
production:
adapter: postgresql
encoding: unicode
database: blog_production
pool: 5
username: myusername
password:
port: 5432
running netstat also looks fine (I think):
$ netstat -a | grep postgre
tcp6 0 0 localhost.postgres *.* LISTEN
tcp4 0 0 localhost.postgresql *.* LISTEN
tcp6 0 0 localhost.postgres *.* LISTEN
which is about everything I could come up with to try and diagnose the problem other than calling a witchdocter :) anyone got any ideas?
EDIT: Solved my question (good old rubber duck debugging) figured I'd post anyway to help any other poor souls that spend an hour digging through and double checking config-files.
Upvotes: 1
Views: 2686
Reputation: 7835
Incorrect config, this was fixed by including the hostname with the configuration (see below), one interesting note is that this is only necessary for the macbook pro that I'm running on and does not occur on the Linux box I use.
development:
adapter: postgresql
encoding: unicode
database: blog_development
pool: 5
username: myusername
password:
host: localhost
port: 5432
test:
adapter: postgresql
encoding: unicode
database: blog_test
pool: 5
username: myusername
password:
host: localhost
port: 5432
production:
adapter: postgresql
encoding: unicode
database: blog_production
pool: 5
username: myusername
password:
host: localhost
port: 5432
Upvotes: 1