Rails 还未配置好 Mina,又出现问题了,本地也跑不起来了,错误:IPAddr::InvalidAddressError: invalid address

drshu · 2016年09月14日 · 最后由 drshu 回复于 2016年09月15日 · 4848 次阅读

运行rails s之后,没有异常,但是打开 localhost 之后,提示We're sorry, but something went wrong.If you are the application owner check the logs for more information.
检查development.log之后,发现错误IPAddr::InvalidAddressError: invalid address,日志截取如下:

Started GET "/" for fe80::1%lo0 at 2016-09-14 13:57:41 +0800

IPAddr::InvalidAddressError: invalid address
    from /Users/Shu/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/ipaddr.rb:560:in `in6_addr'
    from /Users/Shu/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/ipaddr.rb:497:in `initialize'
    from /Users/Shu/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/ipaddr.rb:515:in `new'
    from /Users/Shu/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/ipaddr.rb:515:in `coerce_other'
    from /Users/Shu/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/ipaddr.rb:171:in `include?'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/web-console-3.1.1/lib/web_console/whitelist.rb:17:in `block in include?'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/web-console-3.1.1/lib/web_console/whitelist.rb:17:in `any?'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/web-console-3.1.1/lib/web_console/whitelist.rb:17:in `include?'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/web-console-3.1.1/lib/web_console/request.rb:16:in `from_whitelisted_ip?'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/web-console-3.1.1/lib/web_console/whiny_request.rb:8:in `from_whitelisted_ip?'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/web-console-3.1.1/lib/web_console/middleware.rb:20:in `block in call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/web-console-3.1.1/lib/web_console/middleware.rb:18:in `catch'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/web-console-3.1.1/lib/web_console/middleware.rb:18:in `call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:36:in `call_app'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:24:in `block in call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:70:in `block in tagged'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:26:in `tagged'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:70:in `tagged'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:24:in `call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/sprockets-rails-3.1.1/lib/sprockets/rails/quiet_assets.rb:13:in `call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/request_id.rb:24:in `call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/rack-2.0.1/lib/rack/method_override.rb:22:in `call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/rack-2.0.1/lib/rack/runtime.rb:22:in `call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/executor.rb:12:in `call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/static.rb:136:in `call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/rack-2.0.1/lib/rack/sendfile.rb:111:in `call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0/lib/rails/engine.rb:522:in `call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/puma-3.4.0/lib/puma/configuration.rb:224:in `call'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/puma-3.4.0/lib/puma/server.rb:569:in `handle_request'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/puma-3.4.0/lib/puma/server.rb:406:in `process_client'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/puma-3.4.0/lib/puma/server.rb:271:in `block in run'
    from /Users/Shu/.rvm/gems/ruby-2.3.0/gems/puma-3.4.0/lib/puma/thread_pool.rb:114:in `block in spawn_thread'

查询谷歌之后,找到一个类似情况的,但是没有人给出答案,求指导一下,是不是因为添加了 Mina 的原因?

已解决

使用 -b 来指定一个地址运行即可,例如rails s -b 0.0.0.0

和 Mina 没关系,看起来像是默认用的是 IPV6 走的是 lo0 虚拟网卡。你检查下 Puma 的配置。

#1 楼 @hlcfan 好像没什么问题,这是 Puma 的配置

threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
port        ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "development" }
plugin :tmp_restart

rails s 的时候用 -b 指定一下本地地址试试行不行。

#3 楼 @blacktulip 诶!可以了,但是为什么 localhost 不行了呢?

#4 楼 @drshu 你贴一下 ifconfig 的结果看看?

#5 楼 @blacktulip

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    options=3<RXCSUM,TXCSUM>
    inet6 ::1 prefixlen 128 
    inet 127.0.0.1 netmask 0xff000000 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    nd6 options=1<PERFORMNUD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
    ether **
    nd6 options=1<PERFORMNUD>
    media: autoselect (none)
    status: inactive
en2: flags=963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX> mtu 1500
    options=60<TSO4,TSO6>
    ether **
    media: autoselect <full-duplex>
    status: inactive
fw0: flags=8822<BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 4078
    ladder **
    media: autoselect <full-duplex>
    status: inactive
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether **
    inet6 fe80::8a1f:a1ff:fe26:ff58%en1 prefixlen 64 scopeid 0x7 
    inet 192.168.31.93 netmask 0xffffff00 broadcast 192.168.31.255
    nd6 options=1<PERFORMNUD>
    media: autoselect
    status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
    ether **
    media: autoselect
    status: inactive
bridge0: flags=8822<BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
    options=63<RXCSUM,TXCSUM,TSO4,TSO6>
    ether **
    Configuration:
        id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
        maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
        root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
        ipfilter disabled flags 0x2
    member: en2 flags=3<LEARNING,DISCOVER>
            ifmaxaddr 0 port 5 priority 0 path cost 0
    media: <unknown type>
    status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
    inet6 fe80::2002:1911:69d:5900%utun0 prefixlen 64 scopeid 0xa 
    inet6 fdad:b058:b5ee:81b5:2002:1911:69d:5900 prefixlen 64 
    nd6 options=1<PERFORMNUD>

MAC 地址我已经处理了

huacnlee 关闭了讨论。 09月18日 18:16
需要 登录 后方可回复, 如果你还没有账号请 注册新账号