Saltar al contenido

error: no se pudo conectar a la base de datos postgres: no se pudo conectar al servidor: no existe tal archivo o directorio ¿El servidor se ejecuta localmente y acepta conexiones en el socket de dominio Unix /var/run/postgresql/.s.PGSQL.5432? ejemplo de código de máquina virtual

Este grupo de especialistas luego de algunos días de investigación y de recopilar de información, obtuvieron la respuesta, queremos que resulte de gran utilidad en tu plan.

Ejemplo: psql: no se pudo conectar al servidor: no existe tal archivo o directorio ¿el servidor se ejecuta localmente y acepta conexiones en el socket de dominio de Unix “/var/run/postgresql/.s.pgsql.5432”?

The error states that the psql utility can't find the socket to connect to your database server. Either you don't have the database service running in the background, or the socket is located elsewhere, or perhaps the pg_hba.conf needs to be fixed.

Step 1: Verify that the database is running
The command may vary depending on your operating system. But on most *ix systems the following would work, it will search for postgres among all running processes

ps -ef |grep postgres
On my system, mac osx, this spits out

50140810  2Jul15 ??         0:21.63 /usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log
The last column shows the command used to start the server, and the options.

You can look at all the options available to start the postgres server using the following.

man postgres
From there, you'd see that the options -D and -r are respectively the datadir & the logfilename.

Step 2: If the postgres service is running
Use find to search for the location of the socket, which should be somewhere in the /tmp

sudo find /tmp/ -name .s.PGSQL.5432
If postgres is running and accepting socket connections, the above should tell you the location of the socket. On my machine, it turned out to be:

/tmp/.s.PGSQL.5432
Then, try connecting via psql using this file's location explicitly, eg.

psql -h /tmp/ dbname
Step 3: If the service is running but you don't see a socket
If you can't find the socket, but see that the service is running, Verify that the pg_hba.conf file allows local sockets.

Browse to the datadir and you should find the pg_hba.conf file.

By default, near the bottom of the file you should see the following lines:

# "local" is for Unix domain socket connections onlylocal       all       all       trust
If you don't see it, you can modify the file, and restart the postgres service.

Más adelante puedes encontrar las críticas de otros usuarios, tú además tienes el poder mostrar el tuyo si lo deseas.

¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *