Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Troubleshooting "Permission denied" when attempting to connect to Redis from PHP script

Tags:

php

redis

selinux

Port 6379 is open on the server, and I can successfully run telnet localhost 6379 in SSH.

I tried both Predis/phpredis client library in PHP, but it still does not work:

  • Predis gives "Permission denied" error when opening socket to 6379.
  • phpredis gives "redis server went away".
like image 846
lordlinier Avatar asked Jan 06 '12 23:01

lordlinier


1 Answers

Problem solved, type:

/usr/sbin/setsebool httpd_can_network_connect=1

By default, SELinux does not allow Apache to make socket connections. More information can be found here.

like image 187
lordlinier Avatar answered Sep 25 '22 02:09

lordlinier