I have two servers on EC2. One hosting my php application and other hosting my redis server. I am managing my php session and data on redis server. So on my php server I gave the ip:port as session save path and got the error FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught exception 'RedisException' with message 'Connection closed'
I need to open port 6379 on my redis instance for inbound traffic. I opened it by setting a custom TCP setting in AWS security group but still the port is coming closed to outside world. But I am able to listen to the port on redis server itself. Am i Missing anything in the process? Do I need to make any other change somewhere. Please guide me on this. I am very much new to AWS management On Instance 1: I am using php, Apache and phpredis On Instance 2: Using Redis
But I have Memcached installed on the Instance 2 which is connecting via port 11211 without any issue. I have used the same security rules for Redis
By default redis listens only on 127.0.0.1, and you need to explicitly tell redis to listen on other interfaces or for any node. Depending on your distro, this might be somewhere like
/etc/redis.conf
.On top of that, if you want to let redis listen on all addresses (
0.0.0.0
), you should setproetected-mode no
in redis.conf.When you configure redis, PLEASE for the love of god make sure on your security group settings, you define that the port is open only to the IP or security group of the PHP server that needs to connect to redis, and not to the entire world.
For reference, here's the configuration section from redis.conf about binding: