默认IP和端口 python manage.py runserver 指定端口: python manage.py runserver 192.168.12.12:8080 此时会报错,我们需要修改配置文件: 修改settings.py,将192.168.12.12添加到ALLOWED_HOSTS中 ALLOWED_HOSTS =['172.31.169.182','127.0.0.1','192.168.1.50','192.168.1.115'] 也可以将ALLOWED_HOSTS改成通配符 * ALLOWED_HOSTS = ["*"]