[Fixed]-How to specify which eth interface Django test server should listen on?

45πŸ‘

βœ…

I think the OP is referring to having multiple interfaces configured on the test machine.

You can specify the IP address that Django will bind to as follows:

# python manage.py runserver 0.0.0.0:8000

This would bind Django to all interfaces on port 8000. You can pass any active IP address in place of 0.0.0.0, so simply use the IP address of the interface you want to bind to.

Hope this helps.

πŸ‘€grw

2πŸ‘

Yes, if the IP of your interface is for example 192.168.1.2 and you want to run on port 8080, start the development server like this:

./manage.py runserver 192.168.1.2:8080
πŸ‘€Luper Rouch

1πŸ‘

No. It’s not how it works. The interface has an IP address, you have a network with the test server and your PC. You should connect to that IP (possibly with an alternative port that you specified), and that’s all. If you only have these two devices in the network, it is most likely that both of them should have static IP addresses. (or, if there is not mutual network, you cannot connect to each other).

Leave a comment