handler404 returning Server Error (500) instead of 404.html - Django/Python

I spent several hours on this code and could not get to find out why I am getting server error (500) instead of 404.html in django program. Please see below codes and could someone help?

DEBUG = False

urls.py: (app is mysite)
handler404 = "mysite.views.error_404"

def error_404(request, exception):
    return render(request, '404.html')
{% extends "base.html" %}
{% load static %}
{% block main %}

some html text here

{% endblock %}

Please advise reason why I am not getting 404.html?

Start by looking at your console window where you’re running runserver. It should have the traceback showing where the problem is occurring.

Thank you KenWhitesell for reply, see attached message from the console. image

Django log is not generating traceback. Does attached photo mean much to you? Because I cannot figure out where problem is from.

Are you running this under Django’s runserver?

I see that you’ve got debug = False. That’s going to hide most of the useful information for debugging. Set debug = True and try this again.

Yes, i am running under django’ runserver.

I changed debug = True and then I got Page not found (404) error.

So how are we supposed to deal with that?

Handler404 is not supposed to return a normal HttpResponse, it needs to return an HttpResponseNotFound.

Try getting rid of all the extend commands from your 404 page and render a plain HTML page with no Django extends.

I got this problem this week and this site is one of the first results on google, i would like to answer the question here.
To solve this u need to change the nginx configuration to handle 404 erro.
In my case i had a 404.html page in /path/to/template and i added this lines to .conf file configuration insite server { } part
error_page 404 /404.html;
location = /404.html {
root /path/to/template ;