【问题标题】:in C# Redis : could not connect to redis Instance at 127.0.0.1:6379在 C# Redis 中:无法在 127.0.0.1:6379 连接到 redis 实例
【发布时间】:2015-11-06 15:38:06
【问题描述】:

在 C# 中使用 Redis 服务器。我已经启动了 redis 服务器。

通过c#代码连接redis服务器时

我正在使用 nuget 包 ServiceStack.Redis。

redisClient = new RedisClient("127.0.0.1", 6379);

例外:

base {"无法连接到 redis 实例 127.0.0.1:6379:6379"} System.Exception {ServiceStack.Redis.RedisException}

但我可以通过 server_client.exe 连接到服务器

我们需要做其他事情来连接redis吗?因为我对 redis 完全陌生。

【问题讨论】:

  • 你检查过为什么异常列出了两次端口号吗?

标签: c# redis


【解决方案1】:

如果您想在 127.0.0.1:6379 连接到 redis-server,则需要在本地运行 Redis redis-server。

您可以通过在您尝试与ServiceStack.Redis 连接的同一台服务器上运行redis-cli.exe 来测试redis-server 是否在本地运行。

【讨论】:

  • 感谢mythz,它现在可以工作了,我不知道它背后的原因,但是当我在它上面添加了一个空检查条件时。它开始工作。 if(redisClient==null) redisClient = new RedisClient("127.0.0.1", 6379);
猜你喜欢
  • 2019-02-04
  • 2017-07-06
  • 2023-03-18
  • 2017-05-16
  • 2020-12-04
  • 2022-01-16
  • 2020-08-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多