ruby-on-rails - redis local SocketError : getaddrinfo: nodename nor servname provided, or not known

标签 ruby-on-rails redis

我在我的 Rails 应用程序中安装了 Redis。一切似乎都正常,我在控制台中运行 redis 服务器。所有端口匹配。在我的初始化程序中:

REDIS = Redis.new(:host => 'localhost', :port => 6379)

在控制台中:

[3] pry(main)> REDIS
=> #<Redis client v3.0.2 for redis://localhost:6379/0>

但是当我尝试设置一些东西时:

[4] pry(main)> REDIS.set("hello", "goodbye")
SocketError: getaddrinfo: nodename nor servname provided, or not known
from /usr/local/rvm/gems/ruby-1.9.3-p0@stacksocial/gems/redis-3.0.2/lib/redis/connection/ruby.rb:112:in `getaddrinfo'

谁能解释为什么会这样?

最佳答案

终于明白了。很久以前我编辑了我的主机文件,所以 127.0.0.1 是非常自定义的,并且不能很好地与 redis 一起玩。我将我的主机文件恢复为默认值,现在可以使用了。

关于ruby-on-rails - redis local SocketError : getaddrinfo: nodename nor servname provided, or not known,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13590436/

相关文章:

ruby-on-rails - 检查请求是来自 rails 路由的 xhr 还是 http

ruby-on-rails - Rails 使用 JSON 处理 POST 请求

redis - 如何将用户添加到redis?

redis accumulate & publish 一组操作

ruby-on-rails - Ruby on Rails 教程第 10.4.2 节测试失败

ruby-on-rails - graphql-ruby,日期或日期时间类型

MySQL Rails 迁移错误 : "Error on rename of schema_migration (errno: -1)"

memory - 对象的 Redis 编码和大小影响

java - 如何在两个数据集选项(如 DB)之间使用类似的减法来设计 Redis 搜索/扫描算法

database - 使用像 redistogo.com 这样的服务的优缺点?