Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Django on multiple ports

Tags:

python

django

Could someone tell me how I can run Django on two ports simultaneously? The default Django configuration only listens on port 8000. I'd like to run another instance on port xxxx as well. I'd like to redirect all requests to this second port to a particular app in my Django application.

I need to accomplish this with the default Django installation and not by using a webserver like nginx, Apache, etc.

Thank you


Let's say I two applications in my Django application. Now i don't mean two separate Django applications but the separate folders inside the 'app' directory. Let's call this app1 and app2

I want all requests on port 8000 to go to app1 and all requests on port XXXX to go to app2

HTH.

like image 377
Mridang Agarwalla Avatar asked Oct 07 '10 15:10

Mridang Agarwalla


1 Answers

Just run two instances of ./manage.py runserver. You can set a port by simply specifying it directly: ./manage.py runserver 8002 to listen on port 8002.

Edit I don't really understand why you want to do this. If you want two servers serving different parts of your site, then you have in effect two sites, which will need two separate settings.py and urls.py files. You'd then run one instance of runserver with each, passing the settings flag appropriately: ./manage.py runserver 8002 --settings=app1.settings

like image 147
Daniel Roseman Avatar answered Sep 18 '22 05:09

Daniel Roseman