I am new to using postgres.I have it installed in my computer but as soon as I try running the psql command it throws the following error;
postgres@lennox-ThinkPad-T470s:~$ 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 restarting as per the documentation but it still keeps throwing the same error.
3
Answers
This issue comes from installing the postgres package without a version number. Although postgres will be installed and it will be the correct version, the script to setup the cluster will not run correctly; it’s a packaging issue.
If you’re comfortable with postgres there is a script you can run to create this cluster and get postgres running. However, there’s an easier way.
First purge the old postgres install, which will remove everything of the old installation, including databases, so back up your databases first.. The issue currently lies with 9.1 so I will assume that’s what you have installed
Now simply reinstall
Note the package name with the version number. HTH.
Or try this :
Edit: postgresql.conf
Enable or add:
Restart the database engine:
Also, you can check the file pg_hba.conf
And add your network or host address:
My suggestion is you should see if you have initialized your database for that go to your postgreSQL
name of db cluster is demo
then start the server
then query the server
if you have something running on the port 5434 you can change your port while creating the db and us this command insted
Hope this helps