1

This error is showing after running this command: sudo systemctl status [email protected]

[email protected] - PostgreSQL Cluster 10-main
   Loaded: loaded (/lib/systemd/system/[email protected]; indirect; vendor preset: enabled)
   Active: failed (Result: protocol) since Tue 2020-12-01 14:21:40 UTC; 2s ago
  Process: 1603 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 10-main start (code=exited, sta

Dec 01 14:21:40 ubuntu-s-1vcpu-2gb-sgp1-01 systemd[1]: Starting PostgreSQL Cluster 10-main...
Dec 01 14:21:40 ubuntu-s-1vcpu-2gb-sgp1-01 postgresql@10-main[1603]: Error: Invalid data directory
Dec 01 14:21:40 ubuntu-s-1vcpu-2gb-sgp1-01 systemd[1]: [email protected]: Can't open PID file /va
Dec 01 14:21:40 ubuntu-s-1vcpu-2gb-sgp1-01 systemd[1]: [email protected]: Failed with result 'pro
Dec 01 14:21:40 ubuntu-s-1vcpu-2gb-sgp1-01 systemd[1]: Failed to start PostgreSQL Cluster 10-main.

I have tried all solutions out there. I can't even take backup by pg_dump. Getting the following error while running pg_dump database_name > database_backup.bak:

pg_dump: [archiver (db)] connection to database "database_name" failed: 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"?

Here is the log of permissions of /var/lib/postgresql/10/main:

-rwx------ 1 postgres postgres    3 Apr 28  2020 PG_VERSION
drwx------ 7 postgres postgres 4096 Nov  9 23:36 base
drwx------ 2 postgres postgres 4096 Nov 29 19:28 global
drwx------ 2 postgres postgres 4096 Apr 28  2020 pg_commit_ts
drwx------ 2 postgres postgres 4096 Apr 28  2020 pg_dynshmem
drwx------ 4 postgres postgres 4096 Nov 29 20:18 pg_logical
drwx------ 4 postgres postgres 4096 Apr 28  2020 pg_multixact
drwx------ 2 postgres postgres 4096 Nov 29 19:27 pg_notify
drwx------ 2 postgres postgres 4096 Apr 28  2020 pg_replslot
drwx------ 2 postgres postgres 4096 Apr 28  2020 pg_serial
drwx------ 2 postgres postgres 4096 Apr 28  2020 pg_snapshots
drwx------ 2 postgres postgres 4096 Nov 29 20:18 pg_stat
drwx------ 2 postgres postgres 4096 Apr 28  2020 pg_stat_tmp
drwx------ 2 postgres postgres 4096 Sep  2 00:07 pg_subtrans
drwx------ 2 postgres postgres 4096 Apr 28  2020 pg_tblspc
drwx------ 2 postgres postgres 4096 Apr 28  2020 pg_twophase
drwx------ 3 postgres postgres 4096 Nov 28 01:33 pg_wal
drwx------ 2 postgres postgres 4096 Apr 28  2020 pg_xact
-rwx------ 1 postgres postgres   88 Apr 28  2020 postgresql.auto.conf
-rwx------ 1 postgres postgres   95 Nov 29 19:27 postmaster.opts

Here is the log after running sudo -u postgres psql this command:

 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"?

Please Assist me to fix this. Any kind of help will be appreciated. Thanks in advance.

3
  • See dba.stackexchange.com/questions/209329/… for what Error: Invalid data directory means. postgresql.conf should be in /etc/postgresql/10/main and accessible by postgres. Commented Dec 1, 2020 at 18:59
  • It shows that postgresql.conf was modified recently. Maybe there's something wrong with these changes and the data_directory entry is unreadable or incorrect. Also about the permissions: it's not enough that the leaf directory is accessible. Every directory along the hierarchy must be accessible too. That applies to /etc/postgresql/.... and /var/lib/postgresql/..... Commented Dec 1, 2020 at 19:58
  • pg_ctl: command not found: the look for it and invoke it with its absolute path. Commented Dec 2, 2020 at 8:26

1 Answer 1

0

pid file cannot be created, hence the problem try chmod 777 /var/run/postgressql/

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.