“Could not connect to server: Connection refused” To be sure that PostgreSQL is running, you can also restart it with systemctl restart postgresql. If this does not fix the problem, the most likely cause of this error is that PostgreSQL is not configured to allow TCP/IP connections.
If the connection is still failing, then there might be a permission issue in the pg_hba. conf access configuration file. Make sure this is set up correctly to accept connections from your IP. Finally, ensure there are no firewalls or iptables on the Postgres server that are blocking connections.
If pgAdmin displays this message, there are two possible reasons for this: the database server isn't running - simply start it. the server isn't configured to accept TCP/IP requests on the address shown.
A Connection Timed Out error occurs when the database's firewall won't allow you to connect to the database from your local machine or resource. If you are getting this error, check that you have added the machine or resource you are connecting from to the database's list of trusted sources.
Check there is no postmaster.pid in your postgres directory, probably /usr/local/var/postgres/
remove this and start server.
Check - https://github.com/mperham/lunchy is a great wrapper for launchctl.
For me, this works
rm /usr/local/var/postgres/postmaster.pid
"Postgres.app" is a better fix if you are on OS X
Here is the fix:
cd /varsudo rm -r pgsql_socketsudo ln -s /tmp pgsql_socketchown _postgres:_postgres pgsql_socketMore information is available at "postgresql 9.0.3. on Lion Dev Preview 1".
This worked for me for the error you mentioned. Do one of these:
Possibly change your default port specified in the postgres.conf file,
if you have used something other than the default port 5432 while installing.
Change the port number in postgresql.conf and restart the DB server.
Instead of psql type the full command:
psql -p 5432 -h localhost
If you are running Homebrew, uninstall Postgresql end pg gems:*
$ gem uninstall pg
$ brew uninstall postgresql
Download and run the following script to fix permission on /usr/local:* https://gist.github.com/rpavlik/768518
$ ruby fix_homebrew.rb
Then install Postgres again and pg gem:*
$ brew install postgresql
$ initdb /usr/local/var/postgres -E utf8
To have launchd start postgresql at login run:
$ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Or start manually.
Install pg gem
$ gem install pg
I hope have helped
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