Getting Server Error (500) in Debug = False mode

Hi there. I’m trying to run a project on a server. I moved the project to a Windows server, fixed the database, made collectstatic, since I have little experience I roughly configured nginx, but when I did debug = false I get error 500.

In the Python console shows:

[17/Mar/2025 22:50:20] "GET / HTTP/1.0" 500 145
[17/Mar/2025 22:50:21] "GET / HTTP/1.0" 500 145
[17/Mar/2025 22:50:21] "GET /favicon.ico HTTP/1.0" 500 145
[17/Mar/2025 22:50:22] "GET /favicon.ico HTTP/1.0" 500 145

But the most incomprehensible thing is that I get this error only on the main page of the project, on other pages the project opens and works perfectly.

I searched for a long time for a solution but couldn’t figure it out and decided to remove the favicon.ico altogether, maybe it would help. It didn’t help, but in the debug mode I noticed that even if I removed the favicon from the template in networth the request goes there and shows this error

# Page not found (404)
|Request Method:|GET|
| --- | --- |
|Request URL:|http://127.0.0.1:8000/en/favicon.ico/|
|Raised by:|cms.views.details|

Using the URLconf defined in `vsite.urls`, Django tried these URL patterns, in this order:

en/ jsi18n/ [name='javascript-catalog']
en/ admin/
en/ filer/
en/ news/ [name='news_list']
en/ news/<int:news_id>/ [name='news_detail']
en/ ^cms_login/$ [name='cms_login']
en/ ^cms_wizard/
en/ ^(?P<slug>[0-9A-Za-z-_.//]+)/$ [name='pages-details-by-slug']
en/ ^$ [name='pages-root']
^media/(?P<path>.*)$

The current path, `/en/favicon.ico/`, didn’t match any of these.

Why request still going if i delete facicon on base.html?

my urls.py if it needs

from django.conf import settings
from django.conf.urls.i18n import i18n_patterns
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from django.views.i18n import JavaScriptCatalog
from news.views import news_list, news_detail

urlpatterns = i18n_patterns(
    path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
    path('admin/', admin.site.urls),
    path('filer/', include('filer.urls')),
    path('news/', news_list, name='news_list'), 
    path('news/<int:news_id>/', news_detail, name='news_detail'), 
    path('', include('cms.urls')),
)

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

What kind of code I have to share to explain problem more? or how I can find solution in this situation?

What is your nginx configuration for your server?

How are you running your Django project?

What do the nginx logs show for the requests?

What do your Django logs show for the requests?

I highly recommend setting up sentry. You will then get the full error, and not just the 500 error code.

Settings might be with horrible mistakes, it’s my first time to do production.

NGINX:

server {
        listen       80;
        server_name 172.16.15.247;

        location / {
		proxy_pass http://127.0.0.1:8000; 
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
		
		location /static/ {
        alias C:/vosiquz/vsite/vsite/static/;
    }

		location /media/ {
        alias C:/vosiquz/vsite/media/;   
		expires max;
        access_log off;
    }

Django project runned as default:

python manage.py runserver

I can’t find exacly last nginx error logs, because error.txt is not updated last 2 days. access.txt is looks like this:

172.16.8.191 - - [18/Mar/2025:01:16:56 -0700] "GET / HTTP/1.1" 500 145 "http://172.16.15.247/en/ib-pyp/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"
172.16.8.191 - - [18/Mar/2025:01:16:56 -0700] "GET /favicon.ico HTTP/1.1" 500 145 "http://172.16.15.247/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"
172.16.15.247 - - [18/Mar/2025:21:25:02 -0700] "GET / HTTP/1.1" 500 145 "http://172.16.15.247/en/history-and-traditions/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"
172.16.15.247 - - [18/Mar/2025:21:25:02 -0700] "GET /favicon.ico HTTP/1.1" 500 145 "http://172.16.15.247/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"

Django cmd if I update page in local ip write this:

[18/Mar/2025 21:29:10] "GET /en/ HTTP/1.1" 200 56851
[18/Mar/2025 21:29:10] "GET /static/assets/vendor/bootstrap-icons/bootstrap-icons.css HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/vendor/tiny-slider/tiny-slider.css HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/vendor/font-awesome/css/all.min.css HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/flags/en.svg HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/css/style.css HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/vendor/glightbox/css/glightbox.css HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/vendor/bootstrap/dist/js/bootstrap.bundle.min.js HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/logo-light.svg HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/flags/uz.svg HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/flags/ru.svg HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/logo.png HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/vendor/tiny-slider/tiny-slider.js HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/bg/1.jpg HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/vendor/glightbox/js/glightbox.js HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/js/functions.js HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/client/kiut.png HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/client/kuh.png HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/client/ib.png HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/client/uzbekistan.png HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/client/it-park.png HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/client/akfa.png HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/client/linkedin.svg HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/about/IMG_2183.jpg HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/about/IMG_0010.jpg HTTP/1.1" 500 145
[18/Mar/2025 21:29:10] "GET /static/assets/images/about/IMG_2149.jpg HTTP/1.1" 500 145
[18/Mar/2025 21:29:11] "GET /static/assets/images/about/IMG_2199.jpg HTTP/1.1" 500 145
[18/Mar/2025 21:29:11] "GET /static/assets/images/about/04.jpg HTTP/1.1" 500 145
[18/Mar/2025 21:29:11] "GET /media/news_posters/photo_2024-05-17_18-22-58-1200x675_l3z3DcP.jpg HTTP/1.1" 500 145
[18/Mar/2025 21:29:11] "GET /media/news_posters/photo_2024-05-18_19-31-35-1200x800.jpg HTTP/1.1" 500 145
[18/Mar/2025 21:29:11] "GET /media/news_posters/photo_2024-05-23_10-29-57-1200x900_jHmX5aM.jpg HTTP/1.1" 500 145
[18/Mar/2025 21:29:11] "GET /media/news_posters/0002.jpg HTTP/1.1" 500 145
[18/Mar/2025 21:29:11] "GET /static/assets/images/client/science.svg HTTP/1.1" 500 145
[18/Mar/2025 21:29:11] "GET /static/assets/images/bg/2.jpg HTTP/1.1" 500 145
[18/Mar/2025 21:29:11] "GET /favicon.ico HTTP/1.1" 500 145

if I update page in server ip, write this:

[18/Mar/2025 21:30:20] "GET / HTTP/1.0" 500 145
[18/Mar/2025 21:30:20] "GET /favicon.ico HTTP/1.0" 500 145

Have you read the docs at How to deploy Django | Django documentation | Django (and the links on that page that apply to your situation)?

I suggest paying particular attention to the Deployment checklist | Django documentation | Django

The first thing you want to change:

python manage.py runserver

Quoting directly from the docs for runserver:

DO NOT USE THIS SERVER IN A PRODUCTION SETTING.

You’ll want to set up a real wsgi server for this. A brief web search seems to show that Waitress is a good option.

I don’t know how you have nginx configured for your system, but in the general case, you don’t want your static or media directories to be served from within your project directories. Ideally, you’d want them elsewhere.