'Unable to connect AWS Redis cache in .net C# - RedisConnectionException: 'No connection is active/available to service this operation

I have created AWS ElasticCache - redisCache in console. I want to access same from .net core/framework application - But unable to connect same.

        ConfigurationOptions option = new ConfigurationOptions
        {
           AbortOnConnectFail = false,
           Ssl = true,
           ConnectTimeout =5000,
           KeepAlive = 2,
           EndPoints = { "xxxxxxxxxx.cache.amazonaws.com:6379" }
        };

        ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(option);
        IDatabase db = redis.GetDatabase();
        string value = "abcdefg";
        db.StringSet("mykey", value);
        string getValue = db.StringGet("mykey");
        return getValue;

Gettitng below error -

StackExchange.Redis.RedisConnectionException: 'No connection is active/available to service this operation: SET mykey; UnableToConnect on xxxxx.cache.amazonaws.com:6379/Interactive, Initializing/NotStarted, last: NONE, origin: BeginConnectAsync, outstanding: 0, last-read: 5s ago, last-write: 5s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 5s ago, v: 2.2.88.56325, mc: 1/1/0, mgr: 10 of 10 available, clientName: machineId, IOCP: (Busy=0,Free=1000,Min=8,Max=1000), WORKER: (Busy=1,Free=32766,Min=8,Max=32767), v: 2.2.88.56325'



Solution 1:[1]

In my case the issue was related with the DNS. (I am using a VPN to access Redis). So what I did was put the google DNS in my wifi connection and that did the trick:

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Daniel Silva