First time here? Check out the FAQ!
0

Server runs for some minutes and then 500 error

  • retag add tags

Hi,

I'm running apache2 with wsgi. I've put the website for production yesterday and It was running fine, but now it just sends a 500 error. Restarting apache doesn't seem to solve the issue. This is the error I'm receiving:

 [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
 mod_wsgi (pid=27861): Exception occurred processing WSGI script '/var/www/example/django.wsgi'.
 Traceback (most recent call last):
   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 255, in __call__
     response = self.get_response(request)
   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 178, in get_response
     response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 224, in handle_uncaught_exception
     return callback(request, **param_dict)
   File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 91, in _wrapped_view
     response = view_func(request, *args, **kwargs)
   File "/usr/local/lib/python2.7/dist-packages/django/views/defaults.py", line 41, in server_error
     return http.HttpResponseServerError(template.render(Context({})))
   File "/usr/local/lib/python2.7/dist-packages/coffin/template/__init__.py", line 55, in render
     return super(Template, self).render(**context)
   File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 969, in render
     return self.environment.handle_exception(exc_info, True)
   File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 742, in handle_exception
     reraise(exc_type, exc_value, tb)
   File "/usr/local/lib/python2.7/dist-packages/askbot/templates/500.html", line 1, in top-level template code
     {% extends "two_column_body.html" %}
   File "/usr/local/lib/python2.7/dist-packages/askbot/templates/two_column_body.html", line 1, in top-level template code
     {% extends "base.html" %}
   File "/usr/local/lib/python2.7/dist-packages/askbot/templates/base.html", line 5, in top-level template code
     <title>{% block title %}{% endblock %} - {{ settings.APP_TITLE|escape }}</title>
   File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 397, in getattr
     return getattr(obj, attribute)
 UndefinedError: 'settings' is undefined

I'm running in production mode.

Thanks !

Edit: I discovered that the command touch django.wsgi solves the issue for some minutes. Then the error arises again.

Edit2: Sometimes, when a 500 error arises, reloading the page solves the issue. But visiting any other page will cause the 500 error again, until you reload the page again.

nicanorl's avatar
55
nicanorl
asked 2013-12-13 12:48:22 -0500, updated 2013-12-14 07:10:26 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

2

Create a static robots.txt file served by apache, I observed that when a request for robots.txt hits django an exception is thrown and the app does not go back working normally afterwards. I did not dig into what generates this error but doing this solves it.

odyssey's avatar
48
odyssey
answered 2013-12-15 09:54:50 -0500, updated 2013-12-15 09:59:31 -0500
edit flag offensive 0 remove flag delete link

Comments

Thanks a lot for your help!! I can confirm that "when a request for robots.txt hits django an exception is thrown and the app does not go back working normally afterwards." But I found no way to add a robots.txt file, I will keep trying tomorrow.

nicanorl's avatar nicanorl (2013-12-15 12:20:43 -0500) edit
add a comment see more comments