Friday, 30 January 2015

Django Setting DEBUG = False causes 500 Error - Django 500 error debug false - ALLOWED_HOSTS Problem [SOLVED]

Python Django alirazabhayani Full stack development
Django Debug False 500 error Solved
Being involved in Full Stack Django/Python Web Application Development for 3 years now, I recently deployed my Django application on a test server and encountered Server Error (500) on Django when template debug is set to False. That is in Django settings.py, when I changed DEBUG = FALSE from DEBUG = TRUE, it caused 500 error.

I had upgraded my application from Django 1.4 to Django 1.7. I came to know that 500 error on DEBUG = False error is encountered by everyone using django 1.5 or greater as soon as they change their settings.py to DEBUG = False. Well my problem got solved after reading several blogs and digging deeper in the Django Docs for DEBUG = False ALLOWED_HOSTS settings

What I did was, in settings.py, changed ALLOWED_HOSTS value in the following way:
ALLOWED_HOSTS = ['123.123.198.123']
# Above mentioned IP is not my actual IP. Enter your actual server IP or domain name here. 

If you have a domain name of your server, you may write:
ALLOWED_HOSTS = ['www.example.com']
You can also use a '*' wildcard to allow all hosts. But this is not recommended in the production environment.
ALLOWED_HOSTS = ['*']
You can find a full detail regarding the ALLOWED_HOSTS settings here hidden deep inside django document  

18 comments:

  1. Your my hero. On my blog technelogos.com/blog, I've been trying to solve this error at least for the past few months. Nothing worked until I came across this blog post. I can't thank you enough!

    ReplyDelete
  2. Thanks for sharing. Django is the powerful framework of Python. Kanhasoft is the leading Django web development company in India and USA. With the team of 45 experienced Web developers, we are outsourcing mobile and web application services to Canada, USA, Denmark, Australia, South Africa and more.

    ReplyDelete
  3. Great work man.Thank you
    (https://counfreedise.in/)

    ReplyDelete
  4. Very Helpful and informative blog! Keep sharing such blogsSoftware Development Company in India

    ReplyDelete
  5. Nice! thank you so much! Thank you for sharing. Your blog posts are more interesting and informative. I think there are many people like and visit it regularly, including me. Custom Software Development Services

    ReplyDelete
  6. Great ideas and relevant information about the software developer which are work for their convenience, thank you for the blog here alofatechlabs

    ReplyDelete


  7. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.I want to share about tibco training .

    ReplyDelete
  8. Revolution of Data Science has changed the world with its substantial impact. It is a study of data or information, what it represents, from where it is obtained and how to transform it into a valuable method when formulating business and IT policy. data science course syllabus

    ReplyDelete
  9. This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the leisure here! Keep up the good work. I have been meaning to write something like this on my website and you have given me an idea.

    data science course in India

    ReplyDelete
  10. I just loved your article on the beginners guide to starting a blog.If somebody take this blog article seriously
    in their life, he/she can earn his living by doing blogging.Thank you for this article.
    tibco sportfire online training

    ReplyDelete
  11. I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!
    Artificial Intelligence Course

    ReplyDelete
  12. This is a wonderful article, Given so much info in it, Thanks for sharing. CodeGnan offers courses in new technologies and makes sure students understand the flow of work from each and every perspective in a Real-Time environment AR Training in Vijayawada. ,

    ReplyDelete