PostgreSQL 14 server not running locally on Ubuntu 22.04

Viewed 8

So yesterday I updated my Ubuntu OS from 20 LTS to 22.04 LTS and installed PostgreSQL from this source. Running, psql -V, I get this:

(PostgreSQL) 14.5 (Ubuntu 14.5-1.pgdg22.04+1)

Initialized the postgresql with the following:

$ service postgresql initdb
$ systemctl enable postgresql
$ systemctl start postgresql

When running the psql command, I get the following error:

psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?

Also when runningpg_lsclusters, I get the following:

Ver Cluster Port Status Owner Data directory Log file

And when navigating to postgresql directory ls etc/postgresql/, it has no files or folders in it.

I also installed postgresql-contrib, as mentioned in this source. The reason I looked up this source is that I wanted to initialize the Postgres server, so I followed the commands mentioned in it.

$ sudo systemctl start postgresql.service
$ sudo -i -u postgres
postgres@ror:~$ createuser --interactive
Enter name of role to add: juzershakir
Shall the new role be a superuser? (y/n) y

Get the following error messages:

createuser: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?

And when I check the status of the PostgreSQL service:

$ sudo systemctl status postgresql.service
postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2022-09-09 12:58:06 IST; 49min ago
    Process: 10493 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 10493 (code=exited, status=0/SUCCESS)
        CPU: 1ms

Sep 09 12:58:06 ror systemd[1]: Starting PostgreSQL RDBMS...
Sep 09 12:58:06 ror systemd[1]: Finished PostgreSQL RDBMS.

I am no expert in this, but from this error message, it seems like the service starts and then closes. Why would this be the case? What steps have I missed?


Online sources I have already referred to:

Commands I have tried:

$ sudo ln -s /tmp/.s.PGSQL.5432 /var/run/postgresql/.s.PGSQL.5432
$ sudo service postgresql start --force
$ cat /var/run/postgresql/.s.PGSQL.5432                                                                                                                                   
cat: /var/run/postgresql/.s.PGSQL.5432: No such file or directory
$cd /tmp
l
   rwxrwxrwt   25   root       root         24 KiB   Fri Sep  9 13:58:14 2022    ./
   rwxr-xr-x   20   root       root          4 KiB   Wed Dec 22 11:15:40 2021    ../
   rwx------    2   jsubuntu   jsubuntu      4 KiB   Fri Sep  9 12:32:07 2022    .com.google.Chrome.o8bjs4/
   rwxrwxrwt    2   root       root          4 KiB   Fri Sep  9 12:29:41 2022    .font-unix/
   rwxrwxrwt    2   root       root          4 KiB   Fri Sep  9 12:30:15 2022    .ICE-unix/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:30:14 2022    snap.canonical-livepatch/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:30:15 2022    snap.snapd-desktop-integration/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:30:16 2022    snap.snap-store/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:30:13 2022    systemd-private-64f08d0504e04acfb3259292fa13580c-apache2.service-ZrAICM/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:30:14 2022    systemd-private-64f08d0504e04acfb3259292fa13580c-bluetooth.service-tGJABQ/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:30:17 2022    systemd-private-64f08d0504e04acfb3259292fa13580c-colord.service-En9sFA/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:30:18 2022    systemd-private-64f08d0504e04acfb3259292fa13580c-fwupd.service-okItPb/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:30:13 2022    systemd-private-64f08d0504e04acfb3259292fa13580c-ModemManager.service-KbJJ4J/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:30:13 2022    systemd-private-64f08d0504e04acfb3259292fa13580c-power-profiles-daemon.service-nguChr/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:30:13 2022    systemd-private-64f08d0504e04acfb3259292fa13580c-redis-server.service-EaKdzC/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:30:13 2022    systemd-private-64f08d0504e04acfb3259292fa13580c-switcheroo-control.service-hLF6lp/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:30:13 2022    systemd-private-64f08d0504e04acfb3259292fa13580c-systemd-logind.service-jMNsHm/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:29:41 2022    systemd-private-64f08d0504e04acfb3259292fa13580c-systemd-oomd.service-ZtaPW4/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:29:41 2022    systemd-private-64f08d0504e04acfb3259292fa13580c-systemd-resolved.service-gHZzR9/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:29:41 2022    systemd-private-64f08d0504e04acfb3259292fa13580c-systemd-timesyncd.service-Ycbvmk/
   rwx------    3   root       root          4 KiB   Fri Sep  9 12:30:16 2022    systemd-private-64f08d0504e04acfb3259292fa13580c-upower.service-PBPl2C/
   rwxrwxrwt    2   root       root          4 KiB   Fri Sep  9 12:29:41 2022    .Test-unix/
   rwx------    2   jsubuntu   jsubuntu      4 KiB   Fri Sep  9 12:30:18 2022    tracker-extract-3-files.1000/
   rwxrwxrwt    2   root       root          4 KiB   Fri Sep  9 12:30:15 2022    .X11-unix/
   rwxrwxrwt    2   root       root          4 KiB   Fri Sep  9 12:29:41 2022    .XIM-unix/
   r--r--r--    1   jsubuntu   jsubuntu     11 B     Fri Sep  9 12:30:15 2022    .X0-lock 
   r--r--r--    1   jsubuntu   jsubuntu     11 B     Fri Sep  9 12:30:15 2022    .X1-lock 
$ sudo nano /etc/postgresql/14/main/pg_ident.conf
(Directory doesnt exist)
0 Answers
Related