PostgreSQL error: could not connect to database template1: could not connect to server: No such file or directory

The error means that the Postgres server is not running. Try starting it:

sudo systemctl start postgresql

I believe the service name is postgresql, but if that doesn’t work, try typing

sudo systemctl start postgres

and pressing tab to auto-complete.

Make sure that the server starts on boot:

sudo systemctl enable postgresql

Leave a Comment