I typed psql
and I get this:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
con
Just want to make a small addition: if your instance is complaining on a socket, you can also check unix_socket_directories
at /data/postgresql.conf
file which could have been set to /tmp
, for example, if you have used a 3rd party distribution. You can change it to /var/run/postgresql
and restart the service. That may also require creating a postgresql
dir at /var/run
and subsys/postgresql-9.6
at /var/lock
if those doesn't already exist (worked for me with postgresql 9.6).
It can cause anything for example, my issue was caused for typo error on configuration files. Some of people says caused by certificate files, another group says caused by unmatched locals.
If you cant find any solution about your issue, remove postgres and reinstall it.This is the best solution.
I had the same issue on Devuan ascii (maybe Debian, too?). The config file /etc/postgresql/9.6/main/postgresql.conf
contains a directive unix_socket_directories
which points to /var/run/postgresql
by default. Changing it to /tmp
, where most clients look by default, fixed it for me.
quick howto on debian to remotely access postgres database on server from the psql client: (the changed config is doc'd in the files):
/etc/postgresql/10/main/postgresql.conf
with listen_address */etc/postgresql/10/main/pg_hba.conf
and add line in the end with host all all 0/0 md5
postgres=# CREATE ROLE remoteuser LOGIN WITH PASSWORD 'foo'
sudo /etc/init.d/postgresql restart
changes take effect
login from clientside with psql --host=ipofserver --port=5432 --username=remoteuser --password --dbname=mydb
During fresh installation of postgresql. By default, user name and password is assigned as "postgres". The feature this RDBMS provides is to add role for new user and create database. If you are getting such errors:
login in by default username:
root@kalilinux:~# sudo -i -u postgres
ype psql for interactive prompt
postgres@kalilinux:~$ psql
To quit from prompt use
\q
To create new user role
postgres@kalilinux:~$ createuser --interactive
Now you are in interacive psql shell. Enjoy. Dont forget to login in from your username and type psql for shell.
I had the same problem. It seems that there is no socket when there is no cluster.
The default cluster creation failed during the installation because no default locale was set.