Postgresql server running and verified on 5432 on my localhost system:
If I type: psql -l
I get the following response:
psql: 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"?
If I type psql -h localhost -l
, it works and gives me a list of the databases.
The pg_hba.conf
file is wide open, showing:
TYPE DATABASE USER ADDRESS METHOD
The value "local" is for Unix domain socket connections only:
local all all trust
Allow any IP to connect without password:
host all all 0.0.0.0/0 trust
IPv4 local connections:
host all all 127.0.0.1/32 trust
IPv6 local connections:
host all all ::1/128 trust
What have I missed? On other systems the first call from the command line works fine.
As an alternative you can go to Control Panel -> Systems and Security -> Windows Firewall -> Allow a program or feature through Windows Firewall -> Advanced Settings -> New Rule: Rule Type: Port. TCP or UDP: TCP. Specific local ports: 5432.
Connecting to Your Database The PostgreSQL database service is available on localhost and the default PostgreSQL port is 5432 . A default user ( hosting-db ) and database ( postgres ) exist so you can quickly test your connection and perform management tasks.
The following steps show you how to connect to the PostgreSQL database server via the psql program: First, launch the psql program and connect to the PostgreSQL Database Server using the postgres user: Second, enter all the information such as Server, Database, Port, Username, and Password.
PostgreSQL psql: could not connect to server: Connection refused Step # 1: Allow remote IP address to access PostgreSQL. Now append following line. ... Please replace 192.168.1.0 and... Step # 2: Allow communication over TCP/IP. Save and close the file. Step # 3: Restart PostgreSQL server. This ...
Whereas psql documentation says that: If you omit the host name, psql will connect via a Unix-domain socket to a server on the local host, or via TCP/IP to localhost on machines that don't have Unix-domain sockets.
The default port is 5432. (If you are using Advanced Server this would be 5444.) This is the username that is created while the installation takes place. The default username for postgres is postgres.
It sounds like when you are running the command you are connecting to localhost, not the file socket.. try
psql -h localhost -p 5432
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With