0
using StackExchange.Redis;

namespace Redis
{
    public class Client
    {
        public static readonly ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(new ConfigurationOptions()
            {
                EndPoints = { "localhost" }
            }
        );

        public static double Ping()
        {
            var db = redis.GetDatabase();
            var ping = db.Ping();

            return ping.TotalMilliseconds;
        }
    }
}

Whenever i call redis.GetDatabase() I get the error "It was not possible to connect to the redis server(s) right now".

iKingNinja
  • 113
  • 9
  • is there a redis server on localhost? does it work if you use `127.0.0.1` instead of localhost? is the server running on the default port (6379)? is TLS/auth enabled on the server? – Marc Gravell Apr 24 '23 at 08:26
  • Try specifying the port as well, even if it's the default one: `127.0.0.1:6379`. – Good Night Nerd Pride Apr 24 '23 at 09:24
  • Specifying the port doesn't help, I also tried with a remote redis server and I got the same error. – iKingNinja Apr 24 '23 at 11:43
  • Please look at https://stackoverflow.com/questions/30895507/it-was-not-possible-to-connect-to-the-redis-servers-to-create-a-disconnected. It's may help. – Prasad Ramireddy Apr 30 '23 at 05:36

1 Answers1

0

Turned out it was an issue with the redis server not letting the client connect, but I didn't notice that as it didn't produce any connection error.

iKingNinja
  • 113
  • 9