I'm trying to use Resque in a simple Sinatra app with Passenger/Apache, but get a permission error whenever Resque tries to access Redis. This same error happens with various methods, including Resque.info and Resque.enqueue, and it happens regardless of whether or not redis-server is actually running
If I write the same code in irb or a ruby script, it runs fine.
I have tried switching which users are running both apache/passenger and redis, including root.
App 31099 stdout:
App 31082 stderr: 2015-10-01 12:23:52 - Errno::EACCES - Permission denied - connect(2):
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:122:in `connect_nonblock'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:122:in `connect_addrinfo'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:162:in `block in connect'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:160:in `each'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:160:in `each_with_index'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:160:in `connect'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:211:in `connect'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:322:in `establish_connection'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:94:in `block in connect'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:279:in `with_reconnect'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:93:in `connect'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:350:in `ensure_connected'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:207:in `block in process'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:292:in `logging'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:206:in `process'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:112:in `call'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:1320:in `block in smembers'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:37:in `block in synchronize'
App 31082 stderr: /usr/share/ruby/monitor.rb:211:in `mon_synchronize'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:37:in `synchronize'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:1319:in `smembers'
App 31082 stderr: /usr/local/share/gems/gems/redis-namespace-1.5.2/lib/redis/namespace.rb:393:in `call_with_namespace'
App 31082 stderr: /usr/local/share/gems/gems/redis-namespace-1.5.2/lib/redis/namespace.rb:290:in `method_missing'
App 31082 stderr: /usr/local/share/gems/gems/resque-1.25.2/lib/resque.rb:259:in `queues'
App 31082 stderr: /usr/local/share/gems/gems/resque-1.25.2/lib/resque.rb:431:in `info'
App 31082 stderr: /var/www/html/app.rb:29:in `block in <class:App>'
Found the solution here: Troubleshooting "Permission denied" when attempting to connect to Redis from PHP script
SELinux requires you to explicitly allow Apache to make socket connections.
/usr/sbin/setsebool httpd_can_network_connect=1