0

I'm trying to debug a Server Error 500 with my application. I've read that you should use rhc tail to show a live log stream and with the current error, the log stream that appears when trying to display the page is:

==> app-root/logs/python.log <==

79.24.253.62 - - [01/Jan/2015:08:32:17 -0500] "GET /url/ HTTP/1.1" 500 27 "http://a-b.rhcloud.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36"

The error shown is:

picture showing "Server Error (500)"

Other pages work, this error only appears on certain "more advanced" pages (eg. static pages show correctly). The rest of the log, is:

==> app-root/logs/python.log <==

[Thu Jan 01 08:30:43 2015] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:openshift_t:s0:c6,c654

[Thu Jan 01 08:30:43 2015] [notice] Digest: generating secret for digest authentication ...

[Thu Jan 01 08:30:43 2015] [notice] Digest: done

[Thu Jan 01 08:30:43 2015] [notice] Apache/2.2.15 (Unix) mod_wsgi/3.4 Python/3.3.2 configured -- resuming normal operations

and:

==> app-root/logs/postgresql.log <==

2015-01-01 13:30:25 GMT LOG: shutting down

2015-01-01 13:30:25 GMT LOG: database system is shut down

2015-01-01 13:30:31 GMT LOG: could not bind socket for statistics collector: Permission denied

2015-01-01 13:30:31 GMT LOG: trying another address for the statistics collector

2015-01-01 13:30:31 GMT LOG: could not bind socket for statistics collector: Cannot assign requested address

2015-01-01 13:30:31 GMT LOG: disabling statistics collector for lack of working socket

2015-01-01 13:30:31 GMT WARNING: autovacuum not started because of misconfiguration

2015-01-01 13:30:31 GMT HINT: Enable the "track_counts" option.

2015-01-01 13:30:31 GMT LOG: database system was shut down at 2015-01-01 13:30:25 GMT

2015-01-01 13:30:31 GMT LOG: database system is ready to accept connections

What is the next step to debug this problem?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Shoe
  • 74,840
  • 36
  • 166
  • 272
  • It looks like the error has something to do with how you configured your data base. – fat fantasma Jan 01 '15 at 16:49
  • @fatfantasma There's no custom configuration. – Shoe Jan 02 '15 at 09:44
  • Does your _application_ have a log? – ptrk Jan 08 '15 at 00:47
  • @ptrk You mean log at the application level (custom log)? If so no, the python and database log is shown in the question body. I've tested it locally and it was about `urllib.quote` not existing in Python 3, so I have fixed that. But the problem of "how to debug this kind of errors" remains. :) – Shoe Jan 08 '15 at 07:36
  • Have you set `ALLOWED_HOSTS` in `settings.py`? – timo.rieber Feb 08 '15 at 16:12

1 Answers1

2

I added the following Django logging configuration which gave me the details of the 500 errors in a file django.log. I set LOG_DIR = os.environ.get('OPENSHIFT_LOG_DIR')

LOGGING = {
  'version': 1,
  'disable_existing_loggers': False,
  'handlers': {
    'file': {
      'level': 'WARNING',
      'class': 'logging.FileHandler',
      'filename': os.path.join(LOG_DIR, 'django.log'),
    },
  },
  'loggers': {
    'django.request': {
      'handlers': ['file'],
      'level': 'WARNING',
      'propagate': True,
    },
  },
}
ebug
  • 451
  • 3
  • 18