DalliError: No server available – Using Rails, AWS EC2 and Elasticache

We deployed our Rails application today and found that one of our AWS EC2 servers wasn’t able to connect to our Elasticache instance using the Ruby dalli gem.

DalliError: No server available

Fortunately this isn’t a ruby/rails problem, it’s a permissions issue.

In order to allow an Amazon EC2 instance to access your cache cluster, you will need to grant the EC2 security group associated with the instance access to your cache security group.

Turns out the EC2 instance that wasn’t able to connect to Elasticache, was using a different security group, which we forgot to add to our elasticache instance. Once we did that, we were immediately able to get a connection.