From 84ad63cd184e241185104f89b3cb1bd5ea985388 Mon Sep 17 00:00:00 2001 From: Chris Warrick Date: Thu, 11 May 2017 20:36:57 +0200 Subject: [PATCH] Fix #2755 -- open 127.0.0.1 instead of 0.0.0.0 in serve -b Signed-off-by: Chris Warrick --- CHANGES.txt | 3 +++ nikola/plugins/command/serve.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 2a0743c9ec..a111d37592 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -30,6 +30,9 @@ Features Bugfixes -------- +* Open ``127.0.0.1`` when using ``nikola serve -b`` and default + ``0.0.0.0`` hostname to avoid resolution issues — the site is still + available on all interfaces (Issue #2755) * Don't break animated GIFs in postprocessing (Issue #2750) * More robust shortcodes, no need to escape URLs in reSt, work better with LaTeX, etc. diff --git a/nikola/plugins/command/serve.py b/nikola/plugins/command/serve.py index 5e0f55d497..91eb05750a 100644 --- a/nikola/plugins/command/serve.py +++ b/nikola/plugins/command/serve.py @@ -146,6 +146,8 @@ def _execute(self, options, args): if options['browser']: if ipv6: server_url = "http://[{0}]:{1}/".format(*sa) + elif sa[0] == '0.0.0.0': + server_url = "http://127.0.0.1:{1}/".format(*sa) else: server_url = "http://{0}:{1}/".format(*sa) self.logger.info("Opening {0} in the default web browser...".format(server_url))