¿Por qué recibo un error de no poder conectarme al servidor para postgres en Mac OS Lion?

I just installed postgresql on my Mac OS Lion machine. I've already uninstalled and reinstalled the pg gemas.

Cuando corro psql Obtuve el siguiente 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"?

correr which psql:
/usr/local/bin/psql

I installed postgresql using homebrew

Aquí hay una lsof results for postgres:

postgres  21159 myuser  cwd      DIR               14,2       680 3528182 /usr/local/var/postgres
postgres  21159 myuser  txt      REG               14,2   5092464 3546949 /usr/local/Cellar/postgresql/9.1.3/bin/postgres
postgres  21159 myuser  txt      REG               14,2    599280  641674 /usr/lib/dyld
postgres  21159 myuser  txt      REG               14,2 297734144 3151814 /private/var/db/dyld/dyld_shared_cache_x86_64
postgres  21159 myuser    0r     CHR                3,2       0t0     306 /dev/null
postgres  21159 myuser    1w     REG               14,2      1193 3529245 /usr/local/var/postgres/server.log
postgres  21159 myuser    2w     REG               14,2      1193 3529245 /usr/local/var/postgres/server.log
postgres  21159 myuser    3u   systm                          0t0         
postgres  21159 myuser    4u    unix 0xffffff8012b85578       0t0         ->0xffffff8012b85640
postgres  21159 myuser    5u    IPv6 0xffffff80128f4e80       0t0     TCP localhost:postgresql (LISTEN)
postgres  21159 myuser    6u    IPv4 0xffffff80128f9880       0t0     TCP localhost:postgresql (LISTEN)
postgres  21159 myuser    7u    IPv6 0xffffff80128f5600       0t0     TCP localhost:postgresql (LISTEN)
postgres  21159 myuser    8u    unix 0xffffff80202d9968       0t0         /tmp/.s.PGSQL.5432
postgres  21159 myuser    9u    IPv6 0xffffff8013ebc508       0t0     UDP localhost:57404->localhost:57404
postgres  21170 myuser  cwd      DIR               14,2       680 3528182 /usr/local/var/postgres
postgres  21170 myuser  txt      REG               14,2   5092464 3546949 /usr/local/Cellar/postgresql/9.1.3/bin/postgres
postgres  21170 myuser  txt      REG               14,2    599280  641674 /usr/lib/dyld
postgres  21170 myuser  txt      REG               14,2 297734144 3151814 /private/var/db/dyld/dyld_shared_cache_x86_64
postgres  21170 myuser    0r     CHR                3,2       0t0     306 /dev/null
postgres  21170 myuser    1w     REG               14,2      1193 3529245 /usr/local/var/postgres/server.log
postgres  21170 myuser    2w     REG               14,2      1193 3529245 /usr/local/var/postgres/server.log
postgres  21170 myuser    3u   systm                          0t0         
postgres  21170 myuser    4u    unix 0xffffff8012b85578       0t0         ->0xffffff8012b85640
postgres  21170 myuser    5     PIPE 0xffffff8015250290     16384         ->0xffffff8015250810
postgres  21170 myuser    6     PIPE 0xffffff8015250810     16384         ->0xffffff8015250290
postgres  21170 myuser    9u    IPv6 0xffffff8013ebc508       0t0     UDP localhost:57404->localhost:57404
postgres  21171 myuser  cwd      DIR               14,2       680 3528182 /usr/local/var/postgres
postgres  21171 myuser  txt      REG               14,2   5092464 3546949 /usr/local/Cellar/postgresql/9.1.3/bin/postgres
postgres  21171 myuser  txt      REG               14,2    599280  641674 /usr/lib/dyld
postgres  21171 myuser  txt      REG               14,2 297734144 3151814 /private/var/db/dyld/dyld_shared_cache_x86_64
postgres  21171 myuser    0r     CHR                3,2       0t0     306 /dev/null
postgres  21171 myuser    1w     REG               14,2      1193 3529245 /usr/local/var/postgres/server.log
postgres  21171 myuser    2w     REG               14,2      1193 3529245 /usr/local/var/postgres/server.log
postgres  21171 myuser    3u   systm                          0t0         
postgres  21171 myuser    4u    unix 0xffffff8012b85578       0t0         ->0xffffff8012b85640
postgres  21171 myuser    5     PIPE 0xffffff80152501e0     16384         ->0xffffff8015250760
postgres  21171 myuser    6     PIPE 0xffffff8015250760     16384         ->0xffffff80152501e0
postgres  21171 myuser    9u    IPv6 0xffffff8013ebc508       0t0     UDP localhost:57404->localhost:57404
postgres  21172 myuser  cwd      DIR               14,2       680 3528182 /usr/local/var/postgres
postgres  21172 myuser  txt      REG               14,2   5092464 3546949 /usr/local/Cellar/postgresql/9.1.3/bin/postgres
postgres  21172 myuser  txt      REG               14,2    599280  641674 /usr/lib/dyld
postgres  21172 myuser  txt      REG               14,2 297734144 3151814 /private/var/db/dyld/dyld_shared_cache_x86_64
postgres  21172 myuser    0r     CHR                3,2       0t0     306 /dev/null
postgres  21172 myuser    1w     REG               14,2      1193 3529245 /usr/local/var/postgres/server.log
postgres  21172 myuser    2w     REG               14,2      1193 3529245 /usr/local/var/postgres/server.log
postgres  21172 myuser    3u   systm                          0t0         
postgres  21172 myuser    4u    unix 0xffffff8012b85578       0t0         ->0xffffff8012b85640
postgres  21172 myuser    5     PIPE 0xffffff801449a650     16384         ->0xffffff8014497d10
postgres  21172 myuser    6     PIPE 0xffffff8014497d10     16384         ->0xffffff801449a650
postgres  21172 myuser    7u     REG               14,2      8192 3529006 /usr/local/var/postgres/global/12174
postgres  21172 myuser    9u    IPv6 0xffffff8013ebc508       0t0     UDP localhost:57404->localhost:57404
postgres  21173 myuser  cwd      DIR               14,2       680 3528182 /usr/local/var/postgres
postgres  21173 myuser  txt      REG               14,2   5092464 3546949 /usr/local/Cellar/postgresql/9.1.3/bin/postgres
postgres  21173 myuser  txt      REG               14,2    599280  641674 /usr/lib/dyld
postgres  21173 myuser  txt      REG               14,2 297734144 3151814 /private/var/db/dyld/dyld_shared_cache_x86_64
postgres  21173 myuser    0r     CHR                3,2       0t0     306 /dev/null
postgres  21173 myuser    1w     REG               14,2      1193 3529245 /usr/local/var/postgres/server.log
postgres  21173 myuser    2w     REG               14,2      1193 3529245 /usr/local/var/postgres/server.log
postgres  21173 myuser    3u   systm                          0t0         
postgres  21173 myuser    4u    unix 0xffffff8012b85578       0t0         ->0xffffff8012b85640
postgres  21173 myuser    9u    IPv6 0xffffff8013ebc508       0t0     UDP localhost:57404->localhost:57404

How do I resolve this error? Thanks!

preguntado el 04 de julio de 12 a las 02:07

Is the PostgreSQL server running on the same machine? Can you check where it is listening for connections (maybe with lsof)? -

How did you install postgresql itself? You mention gems, but those are specifically for ruby libraries. -

I've updated my post to answer your questions. Thanks -

1 Respuestas

Lo primero que debe intentar:

psql -h localhost

It may be that the client and server are trying to use different file locations for the UNIX domain socket. You can avoid this by connecting over tcp/ip.

Respondido el 05 de Septiembre de 12 a las 10:09

Hrmn... I get this error as well. I tried to use psql adding "-h localhost" and it works. But when only psql [database] it doesn't. How do I fix that? - índice

do a search for .s.PGSQL.5432 and then -h /path/to/that/directory instead (or set PGHOST to that path). - chris travers

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.