james.lu.75491856 0 Junior Poster

Web.py outputs 0.0.0.0:8080. On windows, localhost and 0.0.0.0 work. But on mavericks, localhost doesn't work! 0.0.0.0 works, though. Can someone explain what 0.0.0.0 is? Why does web.py say you can enter a ip and port in command line and it will run there? (You can't run on someone else's ip,can you?)

Dani AI

Generated

Short answer for : when a server prints 0.0.0.0:8080 it means "bound to all IPv4 interfaces" (INADDR_ANY). 0.0.0.0 is a bind/wildcard address the OS uses so the server accepts connections on any IPv4 address the machine owns. It is not an address you can type into a browser — use 127.0.0.1 or the machine's LAN/public IP to connect.

Why "localhost" works on some systems but not on Mavericks: many macOS installs put an IPv6 loopback (::1) alongside 127.0.0.1 in /etc/hosts, and clients will prefer IPv6. If web.py (or its underlying server) is listening only on IPv4 (0.0.0.0) then a connection attempted over IPv6 to ::1 will fail even though the process is accepting IPv4 connections. To check and work around this:

  • Inspect hosts and which address localhost resolves to:

    cat /etc/hosts
    ping -c 1 localhost
  • Force an IPv4 request or use the loopback IPv4 address:

    curl -4 http://localhost:8080/
    # or
    http://127.0.0.1:8080/
  • See what the process is listening on:

    lsof -nP -iTCP:8080 -sTCP:LISTEN
    netstat -an | grep 8080

If you want to force the server to listen only on the loopback IPv4 interface (safer for local dev), run a WSGI server bound to 127.0.0.1. Example (works with web.py's WSGI app):

from wsgiref.simple_server import make_server

# app should be your WSGI application, e.g. app.wsgifunc()
httpd = make_server('127.0.0.1', 8080, app.wsgifunc())
httpd.serve_forever()

Alternatively bind to the IPv6 wildcard :: (or configure your web server to accept both stacks) if you need localhost to resolve to ::1. Note: binding to 0.0.0.0 exposes the service to other machines on the network — for development bind to 127.0.0.1 or use a firewall.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.