Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

399
Views
Django + Elastic Beanstalk, 500 Response codes in access_log but nothing in error_log

I have an application setup on Elastic Beanstalk (with an auto-scaling load balancer) using Django. The configuration also uses apache httpd and mod_wsgi.

The app functions correctly but I am seeing an occasional error that for the life of me I cannot debug. This is due to the error itself not appearing in the error_log at any point.

A sample from the access log, (IP addresses omitted):

[15/Apr/2020:01:13:21 +0000] "GET /reroute/agument/ HTTP/1.1" 500 27 "-" ""
[15/Apr/2020:01:13:22 +0000] "GET /reroute/argument/ HTTP/1.1" 302 - "https://www.bing.com/" "Mozilla/5.0 (Linux; Android 4.4.3; KFSOWI) AppleWebKit/537.36 (KHTML, like Gecko) Silk/80.5.3 like Chrome/80.0.3987.162 Safari/537.36"

The top request shows an error request, the bottom a typical request. The main thing I notice here is the absence of a user-agent in the 500 request. Combing through the access_log, every single request of this type is missing the user-agent. I have no specific functionality setup to deter bots/spiders or the like.

These 500 errors happen randomly and have been doing so for the last few months. There have been no reports of these occurring with the end user, which leads me to believe two possibilities:

  1. An incorrect host not specified in Django's ALLOWED_HOSTS setting is being used by someone.
  2. Somehow, a bot/spider is being rejected.

I really want to identify and stop these erroneous requests as it is affecting error reporting for the app itself. What would be the best way to identify the issue here?

The only functionality I have added to my beanstalk environment (through .ebextensions) is:

  • Redirecting Http requests to Https
  • Some Django commands to run on startup
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

OK, so I'm dumb.

The reasons why these error messages were not appearing in my logs was simply a case of them not having a means to be displayed in the logs.

Setting up a simple logging dictionary in Django settings.py suddenly started displaying the stack traces of the 500 errors when they happened. From there, I could see it was a simple unhandled exception:

LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
    "console": {
        "class": "logging.StreamHandler",
    },
},
"loggers": {
    "django": {"handlers": ["console"], "level": "INFO"},
},

}

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!