0

I installed PostgreSQL 12, PostGIS, and pgAdmin4 in server mode. I could access pgAdmin4 through the domain name. However, when I tried to access the PostgreSQL database via QGIS or RStudio it gave the below error:

Is the server running on host <ServerName> and accepting TCP/IP connections on port 5432?

I set my postgresql.conf file with local_address = '0.0.0.0' and pg_hba.conf with

host    all             all             0.0.0.0/0               md5
host    all             all             ::/0                    md5

Even after this change, I could not access the database through QGIS, so I referred to this http://www.project-open.com/en/howto-postgresql-port-secure-remote-access. As per this process, I executed:

firewall-cmd --zone=public --add-port=5432/tcp --permanent
firewall-cmd --reload 

Now, I can access the database through QGIS but cannot access the pgAdmin4 which now gives the error:

The connection has timed out

The server at <ServerName> is taking too long to respond

Execution of $ netstat -na result:

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN
tcp        0    320 45.56.73.78:22          47.185.238.169:50439    ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 :::80                   :::*                    LISTEN
udp        0      0 127.0.0.53:53           0.0.0.0:*
udp6       0      0 ::1:53481               ::1:53481               ESTABLISHED
raw6       0      0 :::58                   :::*                    7

I feel this is due to the firewall changes but I am not experienced enough to figure this out. Any help would be great, Thank you!

Server: Ubuntu 20.04

RBK
  • 375
  • 2
  • 5
  • 12

1 Answers1

0

I resolved this issue by setting the appending the port 80/tcp in the firewall by using the below commands:

Status before appending:

$ firewall-cmd --list-all 
public
  target: default
  icmp-block-inversion: no
  interfaces:
  sources:
  services: dhcpv6-client ssh
  ports: 5432/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

Adding 80/tcp:

$ firewall-cmd --zone=public --add-port=80/tcp --permanent
$ firewall-cmd --reload
$ firewall-cmd --list-all
public
  target: default
  icmp-block-inversion: no
  interfaces:
  sources:
  services: dhcpv6-client ssh
  ports: 5432/tcp 80/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

RBK
  • 375
  • 2
  • 5
  • 12