[Django]-Production django server throwing "NoReverseMatch" while rendering, works on development


The likelihood is that you have an error somewhere else, which is preventing one of your views from being imported – probably a dependency missing on your production server. The reverse-URL functionality works by importing all your views, so if any of them can’t be imported for any reason you’ll see a NoReverseMatch error.



url(r'^$', views.main, name="main-view")

and on template:

<a href="{% url main-view %}"> bla bla blah</a>


I ran into the same thing, and so I tried Paperino’s method of creating an image of the server and then restoring the server to that image, and voila, the template error went away. I have no idea why that works, but it did for me, so I’m not complaining, spent most of the day trying to figure this one out 🙂


Restarting gunicorn service solved my problem:

sudo systemctl restart YOUR_GUNICORN.service

Make sure that you are restarting the right gunicorn service. I was driving myself insane, and then I realized I was restarting the wrong service. You might also try restartingrestart nginx, but it shouldn’t be necesary: sudo systemctl restart nginx

Leave a comment