PostgreSQL CGI socket permission denied error
Problem:
When using the python pgdb module, you get this error:
"pdo_connection_error: 'Unable to connect to the Database: Database specific Error:pg.InternalError
could not create socket: Permission denied"
Solution:
A local variable needs to be set to allow for local database connections.
Use this command to have it have this variable set even after rebooting:
setsebool -P httpd_can_network_connect_db 1
NAME
setsebool - set SELinux boolean value
SYNOPSIS
setsebool [ -P ] boolean value | bool1=val1 bool2=val2 ...
DESCRIPTION
setsebool sets the current state of a particular SELinux boolean or a list of booleans to a given value. The value may be 1 or true or on
to enable the boolean, or 0 or false or off to disable it.
Without the -P option, only the current boolean value is affected; the boot-time default settings are not changed.
If the -P option is given, all pending values are written to the policy file on disk. So they will be persistant across reboots.
AUTHOR
This manual page was written by Dan Walsh <[contact form]>. The program was written by Tresys Technology.
SEE ALSO
getsebool(8), booleans(8), togglesebool(8)