PostgreSQL – How to Allow Access from pgAdmin on Fedora

fedorapostgresql

I don't know if I'm cursed or something, but I can't add postgre server to pgadmin. I'm following guide from computingforgeeks, but it always show following message on creating new server in pgadmin:

Unable to connect to server:

could not connect to server: Permission denied
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?

On service status, it show:

LOG:  listening on IPv4 address "0.0.0.0", port 5432
LOG:  listening on IPv6 address "::", port 5432
LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
LOG:  redirecting log output to logging collector process
HINT:  Future log output will appear in directory "log".

Below is the config:

--postgresql.conf:
listen_addresses = '*'
port = 5432

--pg_hba.conf:
# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             0.0.0.0/0               trust
# IPv6 local connections:
host    all             all             ::/0                    trust
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            ident
host    replication     all             ::1/128                 ident

Netstat :

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN    
tcp6       0      0 :::5432                 :::*                    LISTEN

I've tried searching around but most solutions are around the config files and I believe I've set them properly following the guides and solutions around. Please help…

Best Answer

The answer was in a comment in that tutorial's web page. Unfortunately the tutorial omitted a critically important step.

SELinux prevents the web server (Apache, nginx, etc.) from making outbound network connections by default. You need to configure it to allow the web server to make connections to a database.

You can do that with the appropriate SELinux boolean.

setsebool -P httpd_can_network_connect_db 1