ufw won't allow connections to postgres port 5432
0
votes
1
answer
2348
views
With
ufw disable
on remote postgres system i'm able to connect from my local system
However, the connection does not work when I ufw enable
as shown below:
C:\Users\HOME>telnet 80.240.24.195 5432
Connecting To 80.240.24.195...Could not open connection to the host, on port 5432: Connect failed
Below is my postgres configuration at the time of restart.
cat /etc/postgresql/12/main/postgresql.conf
# - Connection Settings -
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 # (change requires restart)
max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
cat /etc/postgresql/12/main/pg_hba.conf
# 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
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::1/128 md5
telnet works when tried from the postgres host itself, but then I try to make the connection from my local laptop it fails.
root@DKERP:/# ufw status numbered
Status: active
To Action From
-- ------ ----
[ 1] 22 ALLOW IN Anywhere
[ 2] 8069 ALLOW IN Anywhere
[ 3] 443/tcp DENY IN Anywhere
[ 4] 443 DENY IN Anywhere
[ 5] 80/tcp DENY IN Anywhere
[ 6] 80,443,5432/tcp DENY IN Anywhere
[ 7] 80 DENY IN Anywhere
[ 8] 4433/tcp DENY IN Anywhere
[ 9] 5432/tcp ALLOW IN Anywhere
22 (v6) ALLOW IN Anywhere (v6)
8069 (v6) ALLOW IN Anywhere (v6)
443/tcp (v6) DENY IN Anywhere (v6)
443 (v6) DENY IN Anywhere (v6)
80/tcp (v6) DENY IN Anywhere (v6)
80,443,5432/tcp (v6) DENY IN Anywhere (v6)
80 (v6) DENY IN Anywhere (v6)
4433/tcp (v6) DENY IN Anywhere (v6)
5432/tcp (v6) ALLOW IN Anywhere (v6)
Can you please suggest what needs to be further done to get the postgres to connect to work from my local laptop?
Asked by Ashar
(527 rep)
Jan 9, 2022, 02:43 PM
Last activity: May 5, 2025, 02:00 PM
Last activity: May 5, 2025, 02:00 PM