# How to host django on local linux without web server like nginx or apache ?

**URL:** <https://forum.djangoproject.com/t/how-to-host-django-on-local-linux-without-web-server-like-nginx-or-apache/32983>\
**Category:** Deployment\
**Created:** [July 15, 2024, 5:35am UTC](https://forum.djangoproject.com/t/how-to-host-django-on-local-linux-without-web-server-like-nginx-or-apache/32983 "2024-07-15T05:35:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JanaganAltrai](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/janaganaltrai/32/22610_2.png) [@JanaganAltrai](https://forum.djangoproject.com/u/JanaganAltrai)\
**Post date:** [July 15, 2024, 5:35am UTC](https://forum.djangoproject.com/t/how-to-host-django-on-local-linux-without-web-server-like-nginx-or-apache/32983/1 "2024-07-15T05:35:35Z")

</div>

My requirement is to host django backend in local linux machine without using any web servers like apache or nginx. I would like to know how can i do that in a best possible way. Now I am running my backend using python manage.py runserver 0.0.0.0:7000 directly on my local linux machine. Soon, we will be building a machine with good configuration dedicated for backend server. Your suggestion would be highly valuable. Thank you in advance.

---

<div class="post-metadata">

**Author:** ![white-seolpyo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/white-seolpyo/32/22386_2.png) [@white-seolpyo](https://forum.djangoproject.com/u/white-seolpyo)\
**Post date:** [July 15, 2024, 5:42am UTC](https://forum.djangoproject.com/t/how-to-host-django-on-local-linux-without-web-server-like-nginx-or-apache/32983/2 "2024-07-15T05:42:11Z")

</div>

maybe `python manage.py {ip address}:{port}` work.

or run project with gunicorn instead runserver command.

but, this is not good choice.

and it’s possible host ip address via nginx.

---

<div class="post-metadata">

**Author:** ![theorangeone](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/theorangeone/32/21264_2.png) [@theorangeone](https://forum.djangoproject.com/u/theorangeone)\
**Post date:** [July 15, 2024, 10:05am UTC](https://forum.djangoproject.com/t/how-to-host-django-on-local-linux-without-web-server-like-nginx-or-apache/32983/3 "2024-07-15T10:05:31Z")

</div>

For production, you shouldn’t use `runserver` at all - you’ll want a production-grade web server like `gunicorn`. `runserver` isn’t designed for production workloads, and your app can often run twice as fast, if not more, by using something designed for production workloads.

`gunicorn` however generally recommends having a web server in front of it, like nginx, as there are security issues around buffering which having a proxy in the middle helps with. What exactly is stopping you using an extra web server?

If you _really_ need to not use a web server, you need to set the bind address to something publicly accessible (`0.0.0.0` will bind to all IPv4 addresses). You’ll also want to set up TLS certificates, and point `gunicorn` at those, too.

---

<div class="post-metadata">

**Author:** ![JanaganAltrai](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/janaganaltrai/32/22610_2.png) [@JanaganAltrai](https://forum.djangoproject.com/u/JanaganAltrai)\
**Post date:** [July 15, 2024, 10:32am UTC](https://forum.djangoproject.com/t/how-to-host-django-on-local-linux-without-web-server-like-nginx-or-apache/32983/4 "2024-07-15T10:32:48Z")

</div>

[theorangeone](https://forum.djangoproject.com/u/theorangeone) Thank you for the response. You asked the correct question “What exactly is stopping you using an extra web server?”. I am concerned about data privacy and in future we are aim to build a machine only dedicated to web server. I am cautious about using external web servers, especially when dealing with sensitive data. Do you have any more suggestions ?

---

<div class="post-metadata">

**Author:** ![theorangeone](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/theorangeone/32/21264_2.png) [@theorangeone](https://forum.djangoproject.com/u/theorangeone)\
**Post date:** [July 15, 2024, 11:08am UTC](https://forum.djangoproject.com/t/how-to-host-django-on-local-linux-without-web-server-like-nginx-or-apache/32983/5 "2024-07-15T11:08:31Z")

</div>

There’s a big difference between an “external” web server, and an “extra” web server. You can absolutely run nginx on the same machine which runs `gunicorn` - and probably should all the time there’s only 1 server running Django.

When you scale up, you could move nginx out onto its own server, to act as the load balancer between the servers. You could also keep nginx and the TLS termination on the machine running Django, and use a simpler load balancer like HAProxy to balance between the servers. That way, traffic stays completely encrypted until it hits the server running Django.

Either way, I think the question you’re asking isn’t quite right. You _do_ want to run an extra web server like nginx, for the reasons I outlined above. If you want to avoid running another web server externally (either another nginx server, or something like Cloudflare), just don’t use it. Nothing about your Django configuration needs to change, nor even does your infrastructure. Just point your domain at the server, have nginx listening on ports 80 and 443, and only have django listening on say `localhost:8000`.

(Yes, this is a lot of steps - this is what happens when you run an application on a machine directly - you have to deal with things like this).

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 15, 2024, 11:10am UTC](https://forum.djangoproject.com/t/how-to-host-django-on-local-linux-without-web-server-like-nginx-or-apache/32983/6 "2024-07-15T11:10:37Z")

</div>

Welcome @JanaganAltrai !

If you’re concerned about security, then you absolutely want to run a real web server in front of your application. The best reason is specified in the Django documentation.

Quoting directly from the docs for [runserver](https://docs.djangoproject.com/en/5.0/ref/django-admin/#runserver):

> **DO NOT USE THIS SERVER IN A PRODUCTION SETTING.** It has not gone through security audits or performance tests.

Relying upon runserver as your production server makes your environment **less** secure, not more.

---

<div class="post-metadata">

**Author:** ![JanaganAltrai](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/janaganaltrai/32/22610_2.png) [@JanaganAltrai](https://forum.djangoproject.com/u/JanaganAltrai)\
**Post date:** [July 17, 2024, 5:05am UTC](https://forum.djangoproject.com/t/how-to-host-django-on-local-linux-without-web-server-like-nginx-or-apache/32983/7 "2024-07-17T05:05:42Z")

</div>

I am getting it. I really appreciate your time.
