# Django static files in deployment DEBUG = FALSE

**URL:** <https://forum.djangoproject.com/t/django-static-files-in-deployment-debug-false/16675>\
**Category:** Deployment\
**Created:** [October 26, 2022, 10:48pm UTC](https://forum.djangoproject.com/t/django-static-files-in-deployment-debug-false/16675 "2022-10-26T22:48:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andresherrera9](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/andresherrera9/32/4546_2.png) [@andresherrera9](https://forum.djangoproject.com/u/andresherrera9)\
**Post date:** [October 26, 2022, 10:48pm UTC](https://forum.djangoproject.com/t/django-static-files-in-deployment-debug-false/16675/1 "2022-10-26T22:48:31Z")

</div>

Good afternoon, I’ve been having problems with deployment. Specifically when DEBUG = FALSE (whenever DEBUG = TRUE it’s loading all static files without problem). I can’t seem to find the problem, any guidance would be helpfull.

All apps are shown in the image below, taller is the main app. The directory static and staticfiles where created using collectstatic (they have the same files).  
 ![django_1](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/4/47d2143fc06e662a5ef2cbf3efc7ff3d63bd27a5.png)

In settings, the STATIC\_URL, STATIC\_ROOT and STATICFILES\_DIRS are defined as:

![django_2](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/1/1ce9adefd9490a1ac24bca8df3bdc3a229adb211.png)

I add the static(settings…) to urlpatterns only in the urls of the main app taller.

![django_3](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/1/1d9002bc41f236f722a754933a8ba7b7b779eb6a.png).

Whenever I run it with DEBUG = FALSE, I get the 404 error as show below:

 ![django_css](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/f/f7d86dbe8c02dd5d652ab9e402f9b36e7a6fd172.png)

Otherwise with DEBUG = TRUE works fine.

What seems to be off?

---

<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:** [October 26, 2022, 10:58pm UTC](https://forum.djangoproject.com/t/django-static-files-in-deployment-debug-false/16675/2 "2022-10-26T22:58:31Z")

</div>

Review the docs at:

- [How to deploy Django | Django documentation | Django](https://docs.djangoproject.com/en/4.1/howto/deployment/)
- [How to deploy static files | Django documentation | Django](https://docs.djangoproject.com/en/4.1/howto/static-files/deployment/)
- [How to manage static files (e.g. images, JavaScript, CSS) | Django documentation | Django](https://docs.djangoproject.com/en/4.1/howto/static-files/).

Also, you don’t mention how you’re trying to run your Django app in your deployment environment, so I’ll just emphasize this particular lines in the docs for [`runserver`](https://docs.djangoproject.com/en/4.1/ref/django-admin/#runserver):

> **DO NOT USE THIS SERVER IN A PRODUCTION SETTING.**

If you’re not using runserver, then it would help if you describe how you’re running your application and how you have _it_ configured to serve the static files. Also note that in most common situations, you do _not_ want your STATIC\_ROOT to be anywhere within your project directory.

---

<div class="post-metadata">

**Author:** ![Fikralaksana](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/fikralaksana/32/9792_2.png) [@Fikralaksana](https://forum.djangoproject.com/u/Fikralaksana)\
**Post date:** [October 27, 2022, 4:12am UTC](https://forum.djangoproject.com/t/django-static-files-in-deployment-debug-false/16675/3 "2022-10-27T04:12:18Z")

</div>

Django not serving your static files in debug False.  
you need to serve it with web server like nginx, apache or etc.

debug False used in production environment.  
in production environment you used another tools to run django.

I personally set up my project in production using Gunicorn/Uvicorn and Nginx.  
Gunicorn is a tool to run django from your project wsgi (i run my project in localhost). Nginx used as proxy from internet to my localhost. Static file is not yet served with this set up. you need to tell nginx to serve your static files folder.
