That error message means that psql has loaded a config file, the config file says the database should be located in a certain place, but its not.
Firstly, make sure the database is actually running, otherwise it won’t be able to connect to it.
Sometimes, you get this error when you have multiple versions of Postgres installed and you’re running a different version of psql to the database. How do you start postgres?
Are you running psql on your local machine, or on the server? If locally, you’ll need to add connection details to the psql command to connect to the remote database (as, by default, it’ll be looking for the database locally), for example (if your server is 1.2.3.4):