Postgres pg_hba.conf localhost confusion - postgresql

I've run into a scenario where an application couldn't see the database. My pg_hba.conf file had the following:
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
Security aside, the application was telling me it couldn't see the database at all, while other clients could see it:
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
(Sequel::DatabaseConnectionError)
I had to point my application to the public IP of that box, and add that in my pg_hba.conf for it to work. Also, it was confused with localhost, as it apparently looked at the IP6 route then the IP4 route, both throwing an error:
Could not spawn process for application /var/www/pints: The application encountered the following error: PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
(Sequel::DatabaseConnectionError)
Question: What is the best way to force this into using the IP4 route, and to best use IP4 resources to handle communications while on the same box? localhost was blind, as was 127.0.0.1, so I'm confused. Cheers

Related

Connection refused when trying connecting to postgresql

#Edit
Sorry its not connect to PostgreSQL but im trying to connect to materialized shell but it's getting an error like below
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 6875?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 6875?
how can i solve this?
Thanks.

Cannot connect postgreSQL server to pgAdmin 4

I know there are a lot of similar questions on this site, but so far I've been unable to find any answers. I have a postgres 13 server running on a WSL distro, ubuntu 20.04. I am trying to connect a gui to the server. I've tried Postbird and pgAdmin 4, both give me a similar error:
'Unable to connect to server:
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?'
Steps I have tried:
I can connect to the server inside of ubuntu by running psql.
I have changed the postgresql.conf file to include listen_addresses = '*'
I have modified the pg_hba.conf file to look like:
pg_hba.conf
I have confirmed that the server is indeed running on port 5432.
Thanks for reading. Any advice would be greatly appreciated.
Ok! So my issue was indeed the pg_hba.conf file. I had to add a line at the bottom
host all all 0.0.0.0/0 trust
Once I did that, I restarted my server and was able to connect.

Could not access the server :pgAdmin 4

services opened to change it automatic
could not connect to server: Connection refused (0x0000274D/) Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?

pgadmin4 tries to connect to old port but my default port is 5432 - can't login

i cant login to my pgadmin4 panel, I m using postgre12.
When i installed postgres i put the default port to 1111, but then
I changed the port name to default 5432. I checked the postgresql.conf file and the default port is still 5432.
Now when i go to pgadmin4, and try to login with
username - postgres
password - admin or postgres
it gives me this error:
could not connect to server: Connection refused
(0x0000274D/10061) Is the server running on host "localhost"
(::1) and accepting TCP/IP connections on port 1111? could not
connect to server: Connection refused (0x0000274D/10061) Is the
server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 1111?
why is it still referring to this old port 1111?
The problem is with the PgAdmin4 configuration.
Go to server properties -> connections and change the port to 5432

PostgreSQL refuses connection

My PostgreSQL 9.3 server running on windows 8.1 has started to refuse connections. It worked fine last time I used it two weeks ago, but first it had a fatal configuration file (strange because I had not edited it) - so I reset that to the default. Then it refused my connection.
The data/pg_log directory is empty.
Error message:
could not connect to server: Connection refused (0x0000274D/10061) Is
the server running on host "localhost" (::1) and accepting TCP/IP
connections on port 5432? could not connect to server: Connection
refused (0x0000274D/10061) Is the server running on host "localhost"
(127.0.0.1) and accepting TCP/IP connections on port 5432?
The server is running on localhost and should be accepting connections to port 5432 according to the postgresql.conf file.