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

248
Views
Django 3.0.5 with mod_wsgi: AttributeError: 'HttpResponse' object has no attribute '_resource_closers'

I'm getting an error when I deploy Django 3.0.5 under mod_wsgi: AttributeError: 'HttpResponse' object has no attribute '_resource_closers'. I'm running:

  • Python: 3.6.8
  • Django: 3.0.5
  • Apache: 2.4.6
  • mod_wsgi: 4.6.2

Here's the basics of the view causing the error; nothing too exotic (I've simplified the code around meetings_struct):

class MeetingsAPIView(MeetingsBaseView):
    def get(self, request, *args, **kwargs):
        meetings = self.get_meetings()
        meetings_struct = []

        for meeting in meetings:
            meetings_struct.append({
                "id": meeting.id,
                "name": meeting.title,
                "slug": meeting.slug,
            })

        return HttpResponse(meetings_struct, content_type="application/json")

If I activate the venv and use runserver manually on the server on port 80, the same view does not give an error. When the same code and venv are running under Apache, here's the error from Apache's logs:

[Sat Apr 18 16:11:30.683980 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397] mod_wsgi (pid=4154): Exception occurred processing WSGI script '/var/django/sites/mysite-prod/config/wsgi.py'.
[Sat Apr 18 16:11:30.684834 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397] Traceback (most recent call last):
[Sat Apr 18 16:11:30.684891 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397]   File "/var/django/sites/mysite-prod/venv/lib64/python3.6/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
[Sat Apr 18 16:11:30.684903 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397]     response = self.get_response(request)
[Sat Apr 18 16:11:30.684925 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397]   File "/var/django/sites/mysite-prod/venv/lib64/python3.6/site-packages/django/core/handlers/base.py", line 76, in get_response
[Sat Apr 18 16:11:30.684933 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397]     response._resource_closers.append(request.close)
[Sat Apr 18 16:11:30.684964 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397] AttributeError: 'HttpResponse' object has no attribute '_resource_closers'

I've rolled back to a previous version that works, running Django 2.2; the rest of the stack is the same. This one has me puzzled, as using the same deployed code with the same venv that Apache is configured to use works fine under runserver, but errors with mod_wsgi.

I've tried stopping and starting Apache, running the publish process again for a fresh venv and code base, and even rebooting the server. The same error occurs, but only under Apache / mod_wsgi.

Any ideas? I'm puzzled!

over 4 years ago · Santiago Trujillo
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!