I was following the ruby on rails tutorial to run with postgres but when I try the "rake db:create" I get the following error:
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 found this question issuing some similar problem but I couldnt make it work anyway.
Repairing Postgresql after upgrading to OSX 10.7 Lion
I have installed homebrew after reading this question and the path is fine, brew doctor shows me no errors on path.
Grant privileges to a new user We resolve this permission denied error using the command. GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO new_user; The new_user was then able to read data from the table. Similarly, we can also resolve the permission denied error by setting DEFAULT privileges to the user.
The default username for postgres is postgres. (If you are using Advanced Server it is enterprisedb.) On a Mac or Windows, you are able to connect to the default instance by simply hitting enter at the shell or command prompt when trying to run psql and keying in the password.
It is better to use another method like using psql to run a simple query and checking the exit code, e.g. psql -c 'SELECT 1' , or use pg_isready to check the connection status. psql -c "SELECT 1" -d {dbname} > /dev/null || postgres -D /usr/local/var/postgres >postgres.
Instead of troubleshooting your socket file permissions, you could try a TCP connection. Add host: localhost
to your config/database.yml
. Of course, this will only work if postgres is listening for TCP traffic. Postgres listens on port 5432 by default, so netstat -an | grep 5432
will tell you if it is listening.
References
Oh, may be you are open postgre in another application, like pgadmin http://www.pgadmin.org/ Try to close any application that use postgre SQL and run your command again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With