Opened 13 years ago

Closed 13 years ago

#30125 closed defect (invalid)

psql: could not connect to server: Permission denied

Reported by: conradwt (Conrad Taylor) Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 1.9.2
Keywords: lion x86_64 Cc: mww@…, jyrkiwahlstedt
Port: postgresql90-server

Description

Hi, I have followed all the installation steps and all completed successfully. However, the following command fails after I start the server (i.e. sudo port load :

$ psql -d postgres -U postgres
psql: 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"?

The server appears to be started:

postgres         307   0.0  0.0  2445872    544   ??  Ss    1:57PM   0:00.72 postgres: stats collector process     
postgres         306   0.0  0.0  2483084   1780   ??  Ss    1:57PM   0:00.48 postgres: autovacuum launcher process     
postgres         305   0.0  0.0  2482952    576   ??  Ss    1:57PM   0:01.54 postgres: wal writer process     
postgres         304   0.0  0.1  2482952   2488   ??  Ss    1:57PM   0:02.16 postgres: writer process     
postgres         136   0.0  0.1  2482952   4088   ??  S     1:57PM   0:00.30 /opt/local/lib/postgresql90/bin/postgres -D /opt/local/var/db/postgresql90/defaultdb
root              82   0.0  0.0  2467380   1224   ??  Ss    1:57PM   0:00.06 /opt/local/bin/daemondo --label=postgresql90-server --start-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper restart ; --pid=none

However, the last line of the above doesn't specify a numerical value for the PID. Last but not least, I'm using a pre-release version Mac OS 10.7 (Build 11A511).

Change History (4)

comment:1 Changed 13 years ago by jyrkiwahlstedt

Lion is still under NDA, so we'll have to wait for a few days to discuss that here...

comment:2 Changed 13 years ago by p3k (Tobi Schäfer)

I experienced the same problem and worked around it by issuing the following commands:

DIR=/opt/local/var/db/postgresql91/defaultdb
sudo launchctl unload -w /Library/LaunchDaemons/org.macports.postgresql91-server.plist
sudo mkdir -p $DIR
sudo chown postgres:postgres $DIR
sudo su postgres -c "/opt/local/lib/postgresql91/bin/initdb -D $DIR"
sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql91-server.plist
psql -h localhost -U postgres

Do the following if you should get the notorious FATAL: could not create shared memory segment: Cannot allocate memory error after the initdb command:

sudo sysctl -w kern.sysv.shmall=65536
sudo sysctl -w kern.sysv.shmmax=16777216

Hope that helps.

comment:3 Changed 13 years ago by jasonw@…

I was able to get it working with the database I had already configured. It seems that Lion ships with PostgreSQL clients (perhaps after installing Xcode):

$ which psql
/usr/bin/psql
$ psql postgres postgres
psql: 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"?

However, if I force psql to use TCPIP by specifying a hostname, all is well:

$ psql -h localhost postgres postgres
psql (9.0.4)
Type "help" for help.

postgres=#

Alternatively, when I put the MacPorts clients first in my path, I had no problem connecting using Unix domain sockets:

$ export PATH=/opt/local/lib/postgresql90/bin:$PATH
$ which psql
/opt/local/lib/postgresql90/bin/psql
$ psql postgres postgres
psql (9.0.4)
Type "help" for help.

postgres=#

Hope this helps!

comment:4 Changed 13 years ago by jmroot (Joshua Root)

Resolution: invalid
Status: newclosed

If I'm reading comment:3 correctly, there's only a problem if you're not running the psql installed by macports. So there's nothing to fix. Reopen if this is incorrect.

Note: See TracTickets for help on using tickets.