SoFunction
Updated on 2024-11-12

Ways to run a django project specifying IP and port

First, django project startup command

Default IP and port

python  runserver 

specified port

python  runserver 192.168.1.50:8080 

II. Problems encountered

Invalid HTTP_HOST header: '192.168.1.50'. You may need to add '192.168.1.50' to ALLOWED_HOSTS.

Modified to add 192.168.1.50 to ALLOWED_HOSTS

ALLOWED_HOSTS = ['172.31.169.182','127.0.0.1','192.168.1.50','192.168.1.115'] 

It is also possible to change ALLOWED_HOSTS to a wildcard character *

ALLOWED_HOSTS = ['*'] 

The above method of running a django project to specify the IP and port is all I have to share with you, I hope to give you a reference, and I hope you will support me more.