Desperatly seeking help with ALLOWED_HOSTS

47 views
Skip to first unread message

Subodh Nijsure

unread,
Aug 17, 2014, 6:26:40 PM8/17/14
to django...@googlegroups.com
I am totally stumped why I can't get my site to work when DEBUG=False.

I have entered my domain name and IP address in the ALLOWED_HOSTS

I even tried putting '*' in my ALLOWED_HOST but when DEBUG=False I
always get my 400.html page served to me. As soon as DEBUG=True
everything works great.

I have search through google tried all the checks people say to try (
I think) , all my urls end in '/'. none of my local.py or base.py have
DEBUG setting or ALLOWED_HOSTS

ALLOWED_HOSTS = ['1.2.3.4', 'www.myhost.com', '*' , ]

Nothing seems to be working.

I even inserted by own dummy LoginRequierdMiddleware class it does get
called but I don't see anything wrong with request coming in.

class LoginRequiredMiddleware:
def process_request(self, request):
print request

I am running nginx and apache2 in production environment. I am really
stuck , desperately need help!Any clues on how to debug this?

-Subodh

Cal Leeming [iops.io]

unread,
Aug 17, 2014, 6:38:59 PM8/17/14
to django...@googlegroups.com
Can you please send us the traceback of the error generated? (assuming there is one)

Cal



-Subodh

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALr9Q3Y_CvwWo1cPEcmROok13VQOneKnis2m9rwGQULbqo%3DpaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Subodh Nijsure

unread,
Aug 17, 2014, 6:47:26 PM8/17/14
to django...@googlegroups.com
Unfortunately I don't see traceback neither in my nginx log or my
apache log that is what is making it very confusing and difficult to
debug...

-Subodh
> https://groups.google.com/d/msgid/django-users/CAHKQagG%2BoyHxp%3DkOFZLZZBfrVLDcBYpWBPtFRAwKediRdwWkjg%40mail.gmail.com.

Cal Leeming [iops.io]

unread,
Aug 17, 2014, 6:54:23 PM8/17/14
to django...@googlegroups.com
Interesting, you could try removing the 400.html and allow it to raise the original exception that caused it.

You could also try using a different WSGI server, such as uWSGI or gunicorn, as it could be a problem with that.

Another option would be to use something like Sentry to capture the errors, or modify your `settings.LOGGING` to send to stderr.

Cal


Subodh Nijsure

unread,
Aug 17, 2014, 7:57:55 PM8/17/14
to django...@googlegroups.com
Thank you SO MUCH for that suggestion for logger. I have some compress
tags in my templates, but I guess I haven't configured that correctly.
And I was getting following error.


File "/home/ubuntu/.virtualenvs/myvirt/lib/python2.7/site-packages/compressor/base.py",
line 121, in get_filename
filename = self.storage.path(basename)
File "/home/ubuntu/.virtualenvs/myvirt/lib/python2.7/site-packages/django/core/files/storage.py",
line 261, in path
raise SuspiciousFileOperation("Attempted access to '%s' denied." % name)
SuspiciousFileOperation: Attempted access to '/css/bootstrap311.min.css' denied.
Not Found: /accounts/login/

the way I debugged this was creating following setup in my
production.py and then /tmp/debug.log had this error.

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': '/tmp/debug.log',
},
},
'loggers': {
'django.request': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
},
}

I removed the {% compress %} tags from my templates for now so I can
disable DEBUG on my "production/demo" server and everything works
great now!

-Subodh
> https://groups.google.com/d/msgid/django-users/CAHKQagGBpVcETUMDhci1n09qpTg3v6Q_dBtUMGM_Ff%2Bur7%2BobQ%40mail.gmail.com.

Cal Leeming [iops.io]

unread,
Aug 17, 2014, 8:29:55 PM8/17/14
to django...@googlegroups.com
Beautiful, glad you got it sorted out, and thanks for sharing the fix!

Cal


Reply all
Reply to author
Forward
0 new messages