linuxpostgresqlubuntupostgres-9.6

Postgres - Moving Data Folder


I wanted to move my PostgreSQL data folder on my Ubuntu server and I was following this tutorial to move it.

I was able to move it, and update my conf file to point to the new location.

When I go to run Postgres, it starts, but when I try to connect via

sudo -u postgres psql

It gives me this error:

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Any ideas what happened? It says it's running.


Solution

  • After done moving PostgreSQL data directory. Don't forget to restart the PostgreSQL service.

    Check the PostgreSQL status by command ps -ef | grep postgres. -D parameter value should be new directory location.

    ERROR /var/run/postgresql/.s.PGSQL.5432 that's mean your PostgreSQL service not starting up Properly or Failed to when starting up.