Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop showing 0.0.0.0 #1964

Closed
davidism opened this issue Nov 6, 2020 · 2 comments · Fixed by #2010
Closed

stop showing 0.0.0.0 #1964

davidism opened this issue Nov 6, 2020 · 2 comments · Fixed by #2010
Labels
Milestone

Comments

@davidism
Copy link
Member

davidism commented Nov 6, 2020

Not sure how feasible this is, but it's one of the more common questions I see on SO. Users for whatever reason run the dev server on 0.0.0.0, see Running on http://0.0.0.0, then are confused when they can't get to that IP in most browsers or scripts. Maybe if Werkzeug sees that value, it displays a more helpful message with the real ip (or localhost if not possible) and a warning about running the dev server in production. Running on all interfaces (try http://{real ip}). Warning: Don't use the development server in production.

@davidism davidism added the server label Nov 6, 2020
@jab
Copy link
Member

jab commented Nov 9, 2020

Great idea @davidism, I've seen users hit this too, and was impressed when I tried npx @11ty/eleventy --serve for the first time and saw the Browsersync output included my (LAN) external IP, in case that's helpful prior art:

Watching…
[Browsersync] Access URLs:
 -------------------------------------
       Local: http://localhost:8080
    External: http://192.168.0.11:8080
 -------------------------------------
          UI: http://localhost:3001
 UI External: http://localhost:3001
 -------------------------------------
[Browsersync] Serving files from: _site

Something like this would get us that much (based on https://stackoverflow.com/a/28950776):

with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
    try:
        s.connect(('10.255.255.255', 1))  # need not be reachable
        return s.getsockname()[0]
    except Exception:
        return '127.0.0.1'

Not sure it's in scope, but if we wanted to try to get the host's WAN IP, I think we'd either have to try querying the router over UPnP, which requires a UPnP client, as in https://stackoverflow.com/a/41385033:

import miniupnpc
client = miniupnpc.UPnP()
client.discoverdelay = 200
client.discover()
client.selectigd()
return client.externalipaddress()

...or resort to querying some public "what is my IP" service (https://ident.me, http://canhazip.com, etc.) as in https://stackoverflow.com/a/41432835.

@akshgpt7

This comment has been minimized.

@davidism davidism added this to the 2.0.0 milestone Jan 18, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants