How to allow PostgreSQL from pgadmin

Shira Ishikawa asked:

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 "" and accepting
TCP/IP connections on port 5432?

On service status, it show:

LOG:  listening on IPv4 address "", 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:

listen_addresses = '*'
port = 5432

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all                  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               ident
host    replication     all             ::1/128                 ident

Netstat :

tcp        0      0    *               LISTEN     
tcp        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…

My 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

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.