Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#396 closed defect (invalid)

djangoadmin.py runserver should be able to listen on all available IPs

Reported by: mgood Owned by: adrian
Component: Tools Version:
Severity: normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Since [539] the built-in Django server will only listen on 127.0.0.1 if an IP address is not specified. So, if you want to access the Django server from another machine you have to fill in the full IP of the server. I think that by default the server should use the empty string for the IP so that the server listens on all available IP addresses.

Change History (3)

comment:1 Changed 10 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

This is by design; you should have to explicitly reveal the server on external addresses if you know you want to -- otherwise inexperienced users could accidentally expose development servers.

comment:2 Changed 10 years ago by Matthew Good <trac@…>

  • Resolution wontfix deleted
  • Status changed from closed to reopened

Ok, listening on the loopback is a decent default, but I'd rather not have to type my IP when I'm running the server, plus there's now no way to allow it to listen on all addresses, so "localhost" won't work at the same time as an external IP. The following patch allows specifying the address as "*" which will make the server listen on all IPs.

  • django/core/management.py

     
    549549    from django.core.handlers.wsgi import WSGIHandler
    550550    if not addr:
    551551        addr = '127.0.0.1'
     552    elif addr == '*':
     553        addr = ''
    552554    if not port.isdigit():
    553555        sys.stderr.write("Error: %r is not a valid port number.\n" % port)
    554556        sys.exit(1)
     
    557559        print "Validating models..."
    558560        validate()
    559561        print "\nStarting server on port %s with settings module %r." % (port, SETTINGS_MODULE)
    560         print "Go to http://%s:%s/ for Django." % (addr, port)
     562        print "Go to http://%s:%s/ for Django." % (addr or '127.0.0.1', port)
    561563        print "Quit the server with CONTROL-C (Unix) or CTRL-BREAK (Windows)."
    562564        try:
    563565            run(addr, int(port), AdminMediaHandler(WSGIHandler()))

comment:3 Changed 10 years ago by Boffbowsh

  • Resolution set to invalid
  • Status changed from reopened to closed

Use runserver 0.0.0.0:8000 to make it listen on all interfaces

Note: See TracTickets for help on using tickets.
Back to Top