Issues while connecting psql
Solution 1
The permissions and ownership on /var/lib/pgsql/data
should be:
# ll -d /var/lib/pgsql/data
drwx------. 15 postgres postgres 4096 Apr 24 10:27 /var/lib/pgsql/data
If they are not do as root:
# chmod -R 700 /var/lib/pgsql/data
# chown -R postgres /var/lib/pgsql/data
Solution 2
Check in the pglog.log
file to ensure that the server did actually start without error. Given the error it seems like it did not start properly.
Solution 3
You probably don't have your server configured to put unix domain sockets in "/tmp". It's probably somewhere like "/var/run/pgsql" but see your postgresql.conf
file to see exactly what.
Then you can specify this directory as a "host" on the command-line:
psql -h /path/we/want ...
If that's not the problem, check the port number.
Not sure why/how your psql client and postgresql server have different default paths, but then I've never heard of the site you got the instructions from, so I've no idea how useful they are.
user1778824
Updated on June 05, 2022Comments
-
user1778824 almost 2 years
I installed postgresql in accordance with the instructions given at: http://xadmin.info/?p=284
# pg_ctl -D /var/lib/pgsql/data -l pglog.log start server starting postgres@linux-p0pl:~> psql psql: 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"?
I am not getting as to why am I getting this error when the server has started...can someone please please help.
My pglog.log file shows the following output:
2013-02-06 19:43:39 GMT FATAL: lock file "postmaster.pid" already exists 2013-02-06 19:43:39 GMT HINT: Is another postmaster (PID 23971) running in data directory "/var/lib/pgsql/data"? 2013-02-06 19:44:02 GMT FATAL: lock file "postmaster.pid" already exists 2013-02-06 19:44:02 GMT HINT: Is another postmaster (PID 23971) running in data directory "/var/lib/pgsql/data"? 2013-04-24 12:43:29 GMT FATAL: data directory "/var/lib/pgsql/data" has group or world access 2013-04-24 12:43:29 GMT DETAIL: Permissions should be u=rwx (0700). 2013-04-24 12:44:07 GMT FATAL: data directory "/var/lib/pgsql/data" has group or world access 2013-04-24 12:44:07 GMT DETAIL: Permissions should be u=rwx (0700). 2013-04-24 12:57:02 GMT FATAL: data directory "/var/lib/pgsql/data" has group or world access 2013-04-24 12:57:02 GMT DETAIL: Permissions should be u=rwx (0700). 2013-04-24 12:57:40 GMT FATAL: data directory "/var/lib/pgsql/data" has group or world access 2013-04-24 12:57:40 GMT DETAIL: Permissions should be u=rwx (0700).
ps -ef | grep postgres
root 21659 21591 0 19:14 pts/0 00:00:00 grep --color=auto postgres
-
user1778824 almost 11 yearsI have posted my pglog.log file's content. Hope that will help u in helping me further
-
Ed Plese almost 11 yearsIt's listing a number of fatal errors regarding permissions so I would check that first as well as ensuring that a separate Postgres process is not already running which the logs also note.
-
user1778824 almost 11 yearsWith psql -h localhost. I get: psql: could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
-
user1778824 almost 11 yearsThanks for helping. Hopefully the above command will help you in helping me further
-
user1778824 almost 11 yearshow do i check that an stop the separate postgres process
-
Ed Plese almost 11 yearsThe
postmaster.pid
file should contain the process ID and then you can check to see if that process is still running. -
Richard Huxton almost 11 yearsNo. Because you've switched from domain sockets to tcp/ip via localhost. Get a coffee, find your postgresql.conf file and read through it and the configuration section of the online manuals.
-
Ed Plese almost 11 yearsTo add to my last comment the PID is listed on the first line in
postmaster.pid
. -
user1778824 almost 11 yearsI have uncommented my listen_address='localhost' and port=5432 in postgresql.conf...still i am getting the same error. I know this may sound insane but I am a novice at postgresql..therefore pls please excuse
-
user1778824 almost 11 yearspostmaster.pid file does not exist on my system. My system gives "pg_ctl: PID file "/var/lib/pgsql/data/postmaster.pid" does not exist"..now how do i check
-
Ed Plese almost 11 yearsCan you try
ps -ef | grep postgres
and see if any processes are running that way? -
user1778824 almost 11 yearsroot 21606 21591 0 19:06 pts/0 00:00:00 su - postgres postgres 21607 21606 0 19:06 pts/0 00:00:00 -bash postgres 21648 21607 0 19:08 pts/0 00:00:00 ps -ef postgres 21649 21607 0 19:08 pts/0 00:00:00 grep --color=auto postgres
-
user1778824 almost 11 yearsThe above is the output which it gives me
-
user1778824 almost 11 yearsroot 21659 21591 0 19:14 pts/0 00:00:00 grep --color=auto postgres is the output which i get..sorry for the previous output
-
user1778824 almost 11 yearsThanks a lot for replying. But even after changing permission and ownership it is giving me the same error..psql: 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"?
-
user1778824 almost 11 yearspostgres was working fine before I changed the pg_hba.conf file to: # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/32 trust # IPv6 local connections: host all all ::1/128 trust
-
user1778824 almost 11 yearsI tried to restore the above changes from trust to ident and peer..however my error persists
-
Clodoaldo Neto almost 11 yearsThe last error from the pglog.log you posted is about permissions. Is it the same now? Did you change pg_hba as the postgres user?
-
user1778824 almost 11 yearsThanks a lot. Now my problem w.r.t psql is indeed solved. Can you also help me with this...I am now getting the error "FATAL: Ident authentication failed for user "postgres"". Even though I changed ph_hba's method to trust still I am getting the error of authentication failure. Thanks a lot again..hope u will also solve this problem of mine...please please
-
user1778824 almost 11 yearsAs soon as I restart the server after making the changes with rcpostgresql restart..I again start getting the same error as posted in the question
-
Clodoaldo Neto almost 11 years@user What are the last errors in pglog.log? When you saved pg_hba as root it became unreadable by postgres which is (or should be) the user the postgresql processes run as. Only edit those files as postgres. Check the permissions and ownership or just run the commands in my answer again.