Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

416
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda