简体   繁体   中英

Postgres Server error -> PGError: could not connect to server

I get the error below when trying to start my rails app on the localhost:

PGError (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"?

From what I have read it sounds like this is most likely a problem in connecting to the Postgres server, and may indicate that it is not started?

It all started when I was attempting my first (yay noobs!) merge using git. There was a conflict (having to do with the Rubymine workspace.xml file), and I started to open up a conflict resolution program. It then seemed that there was really no need to track workspace.xml at all and so I quit from the resolution program, intending to run "git rm --cached" on the file. I think in quitting the program something went foul, and I ended up restarting, before untracking the file, and then completing the merge. Further evidence that something was gummed up is that my terminal shell didn't open up correctly until I restarted the machine.

Now, as far as I can tell, everything in the merge went fine (there were trivial differences in the two branches anyway), but for the life of me I can't seem to get rid of this PGError. If it is as simple as starting the server, then I'd love help on how to do that.

(other context: OSx, rails 3, posgresql83 installed via macports, pg gem).

EDIT - I have been trying to start up the server, but am not succeeding. eg, I tried:

pg_ctl start -D /opt/local/var/db/postgresql83/defaultdb

This seems to be the right path for the data (it finds the postgresql.conf file) but the response I get is "cannot execute binary file."

and may indicate that it is not started?

Yes, sounds like the server is not running on your local machine.

See the description of this error in the PostgreSQL manual:
http://www.postgresql.org/docs/8.3/static/server-start.html#CLIENT-CONNECTION-PROBLEMS

Try sudo port load postgresql83-server - this should work with the latest 8.3 port from macports.

If this doesn't work, try sudo port selfupdate; sudo port upgrade outdated sudo port selfupdate; sudo port upgrade outdated and then try again.

Note - this may take absolutely ages.

To start the server, try something along the following lines (adjust for pgsql version # and logfile):

sudo su postgres -c '/opt/local/lib/postgresql84/bin/pg_ctl -D /opt/local/var/db/postgresql8/defaultdb -l /opt/local/var/log/postgresql84/postgres.log start'

To stop the server,

sudo su postgres -c '/opt/local/lib/postgresql84/bin/pg_ctl -D /opt/local/var/db/postgresql84/defaultdb stop'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM