Skip to content

Instantly share code, notes, and snippets.

@rririanto
Last active April 19, 2016 06:28
Show Gist options
  • Save rririanto/65801a3008c21bb0a5594c2abcc12540 to your computer and use it in GitHub Desktop.
Save rririanto/65801a3008c21bb0a5594c2abcc12540 to your computer and use it in GitHub Desktop.
[SOLVED] Django AWS ec2 Unhandled Exception An unhandled exception was thrown by the application.
"
Problem:
Server Nginx
Django
Unhandled Exception An unhandled exception was thrown by the application.
"
The Story when i try to deploy a new code in new staging server on aws ec2.
i was intalling anything before. library, dependency and etc
but when i'm running it i got an error message
"Unhandled Exception An unhandled exception was thrown by the application."
WTF. did i miss something ?? I'm not preparing for any watchdog things. because its a new server.
Im trying to trace the logs by /var/log/nginx/ but i didn't found the real error.
i also enable DEBUG=TRUE and the result still same "Unhandled Exception An unhandled exception was thrown by the application."
I think i should running python manage.py runserver to see the real error.
because i'm usually running the code in server by runfcgi associated with nginx config.
let's try with public ip 59.120.48.109:8000
python manage.py runserver 59.120.48.109:8000
Validating models...
0 errors found
Django version 1.4.21, using settings 'x5xLXanalytics.settings'
Development server is running at http://59.120.48.109:8000/
Quit the server with CONTROL-C.
Error: That IP address can't be assigned-to.
Damnnn LOL. aws ec2 doesnt let me assigned the public ip. yeah i know it this is stupid. lol
oh lets try with local ip.
python manage.py runserver
Validating models...
0 errors found
Django version 1.4.21, using settings 'x5xLXanalytics.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Yeah. it works !!? so then how i check/watch the error in my browser while the ip addr is local ip ??
LOL this is sick man..
Ohh Wait !! I got an Idea.
I login to my server over ssh in another terminal while keeping my first terminal session open.
then I do
$ wget http://127.0.0.1:8000/
--2016-04-19 05:03:42-- http://127.0.0.1:8000/
Connecting to 127.0.0.1:8000... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2016-04-19 05:03:42 ERROR 500: Internal Server Error.
what the hell. WGET ??
So, lets see in first terminal. is there any error message shown up ?
YES..
python manage.py runserver
Validating models...
0 errors found
Django version 1.4.22, using settings 'x5xLXanalytics.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/home/ubuntu/myproject/local/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
return self.application(environ, start_response)
File "/home/ubuntu/myproject/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
self.load_middleware()
File "/home/ubuntu/myproject/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 45, in load_middleware
raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
ImproperlyConfigured: Error importing middleware ratelimit.middleware: "No module named ratelimit.middleware"
[19/Apr/2016 00:03:42] "GET / HTTP/1.1" 500 59
WWhoaahhh. Finally.. !!
So. Now the Problem is "I fucking forget to install the latest lib "No module named ratelimit.middleware".
Close Enough. now problem has been fixed.
Nb: IM A LAZY PERSON. this problem can be fixed by elegant way. coding/install or more and etc.
but FUCK yeah. IM LAZY & I Will try to find Simple & Short way to Fix My Fucking Problem. :P LOL
Enjoy the story !!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment