As per the log files, I am getting the below errors.

The program "postgres" was found by "/usr/lib/postgresql/12/bin/pg_ctl" but was not the same version as pg_ctl. Check your installation.

I am running Ubuntu 20.04.

I executed the following commands to determine which versions are running:

# /usr/lib/postgresql/12/bin/postgres --version
postgres (PostgreSQL) 12.16 (Ubuntu 12.16-0ubuntu0.20.04.1)
# /usr/lib/postgresql/12/bin/pg_ctl --version
pg_ctl (PostgreSQL) 12.15 (Ubuntu 12.15-0ubuntu0.20.04.1)

Do I need to update or perform some tasks as the current situation has rendered my DB Server useless and I have some databases which I am not able to access?

Also, now when I run the command, I get this error:

postgres@tvsr-strapi:~$ psql
psql: error: 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"?

I have tried recreating the symbolic link, it still doesn't work.

  • Everything was working perfectly fine but then all of a sudden I am seeing this error. Nov 2, 2023 at 9:44

1 Answer 1


Since I was not able to restart my PostgreSQL Server, I decided to copy the data files located in /etc/postgresql/12/main to another server and check if it works.

While trying to test this on a new Server, I installed the same version of PostgreSQL 12 and then tried checking the version info of the pg_ctl and postgres.

postgres (PostgreSQL) 12.16 (Ubuntu 12.16-0ubuntu0.20.04.1)

pg_ctl (PostgreSQL) 12.16 (Ubuntu 12.16-0ubuntu0.20.04.1)

I was surprised to see that the versions were same unlike in my present server. So, I decided to simply copy the binary files from my new server to my old one from the location /var/lib/postgresql/12.

Once this was done, my PostgreSQL started without any issues or complaints. I know this may not be the best approach, but it worked and allowed me to take a dump of the data.

Although the question still remains as to how the version changed for the old server?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.