diff --git a/middleman-core/lib/middleman-core/preview_server.rb b/middleman-core/lib/middleman-core/preview_server.rb index bc3f71e4..ad52ce7b 100644 --- a/middleman-core/lib/middleman-core/preview_server.rb +++ b/middleman-core/lib/middleman-core/preview_server.rb @@ -272,7 +272,8 @@ module Middleman # An IPv4 address on this machine which should be externally addressable. # @return [String] def public_ip - Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }.ip_address + ip = Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? } + ip ? ip.ip_address : '127.0.0.1' end end