I want to connect to a pgAdmin 4 database by a remote server. However, when I want to save the connection properties, I get the following message:
unable to connect to server: timeout expired
This the content of the "pg_hba.conf":
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all scram-sha-256
# IPv4 local connections:
host all all 127.0.0.1/32 scram-sha-256
# IPv6 local connections:
host all all ::1/128 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all scram-sha-256
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256
listen_addresses in "postgresql.conf" is also set to '*'
What should I do to be able to connect to the server remotely?
Related
I get following error when I try to connect using Beekeeper-Studio :
no pg_hba.conf entry for host "105.104.156.80", use"sdgij;sdhfhhuih", database"uhoidfgiosdff", no encryption
Here is my pg_hba.conf file:
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
Your database server is only accepting connections from local clients:
host all all 127.0.0.1/32 md5
You need to add a line to pg_hba.conf that allows connections from your local network, something like so:
host all all 105.104.156.0/24 md5
But you should be VERY cautious with making changes to pg_hba.conf as you can let in hackers on your server if not careful. See the documentation for details. In particular, you should reduce the allowed address range, the database to connect to and possibly the list of allowed users.
I know this question has been asked several times before, but all answers I could find tell you to add a line like the following to the pg_hba.conf file:
host all all 127.0.0.1/32 md5
So my pg_hba.conf file now looks like this:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident
# I've added the following lines:
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
host all all 192.168.0.0/24 md5
I have set up several postgresql servers in the past on ubuntu and never had a problem. However, on fedora, I still get the following error message:
FATAL: Ident authentication failed for user "postgres"
The server is running on Fedora 27 Workstation and the postgresql version is 9.6.8-1.fc27.
You have two authentication rules for localhost in your pg_hba.conf, namely ..
host all all 127.0.0.1/32 ident
and
host all all 127.0.0.1/32 trust
I believe the system is trying to validate the two authentication options, making the trust option being overwritten by ident. Since you're most likely trying to use trust to authenticate from localhost (based on your file), just comment/delete the following line:
host all all 127.0.0.1/32 ident
And afterwards either restart your database or reload the conf file using the following query:
SELECT pg_reload_conf();
I have created a docker image with playframework backend that connects to pgsql localhost database. It is running smoothly when I run it in my local machine but when I run it in docker I receive errors.
I want to connect the docker container to my posgresql localhost.
I have tried configuring postgresql.conf and pg_hba.conf to open the port 5432
pg_hba.conf
# TYPE DATABASE USER ADDRESS
METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 192.168.1.0/24 trust
host all all 172.17.0.0/16 trust
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::1/128 trust
host all all ::/0 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all 172.17.0.0/32 trust
host replication all ::1/128 trust
postgresql.conf
listen_addresses = '*'
# what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432
When running my playframework app. I am getting the error below
Caused by: com.zaxxer.hikari.pool.PoolInitializationException: Exception during pool initialization
Caused by: org.postgresql.util.PSQLException: The connection attempt failed.
On a side note, postgresql is installed using brew, running correctly can access database using pgadmin4.
I get the following error:
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres"
here is what my pg_hba.conf loooks like
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres md5
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
Also I have successfully logged in from the command line using the user postgres
I am using pgAdmin 4 on a MAC.
Having difficulty getting Mezzanine to connect to Postgresql via Docker
In my postgresql.conf I have:
listen_addresses = '*'
In my pg_hba.conf I have:
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
host all all samenet trust
host all all 0.0.0.0/0 md5
The error I keep getting is:
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?
I have PORT in settings.py set to '' but I have PORT defined in postgresql.conf to 5432.
Any suggestions?
Ensure that port mapping is properly configured https://docs.docker.com/userguide/dockerlinks/
If your app is running in one container and postgresql server is running in another container, you need to link containers together.
By the way you are trying to establish connection via localhost and you have md5 authentication method there. For debug purposes change authentication method to trust. You should EDIT this line in your pg_hba.conf NOT to ADD another line.
host all all 127.0.0.1/32 md5
The best way to debug connection issues is to use psql utility.