CentOS7 php redis server – permission denied

Fresh installation of redis, out of the box and it doesn’t work.
Never had this issue on Ubuntu ..

Warning: Redis::connect(): connect() failed: Permission denied in /var/www/vhosts/xxx/httpdocs/_/_.redis.php on line 12

We need to enable httpd to use redis’ default port 6379:

yum install policycoreutils-python
semanage port -m -t http_port_t -p tcp 6379
semanage port -l | egrep '(^http_port_t|6379)'
http_port_t tcp 6379, 80, 81, 443, 488, 8008, 8009, 8443, 9000
redis_port_t tcp 6379

No need to restart redis or httpd after this, it should work right away.

Write a Comment


  1. Vᥱry gⲟod informаtion. Lucky me I came aϲross your blog by accident (stumbleսpon).

    I have saved it for later!

  2. Thanks so much for posting this.
    I ran into the exact same problem when trying to set up a php 7 installation on a different TCP port to the default 9000 that php 5.6 was using.
    php-fpm service was happy to listen on whatever port I specified in http://www.conf, but nginx would give an error when trying to connect to php-fpm:
    (13: Permission denied) while connecting to upstream, client:, server: http://www.local, request: “GET / HTTP/1.1”, upstream: “fastcgi://”

    Unfortunately, semanage refused to link some tcp ports Error: “ValueError: Port @tcp/9712 is not defined”, but it worked when I chose port 9002.