No module named 'application' deploying Django 4.0 to AWS Beanstalk

When I try to deploy my project to AWS beanstalk I keep on getting the same error in my logs "ModuleNotFoundError: No module named 'application'". Because of this I get 502 Bad Request errors. I am using Django 4.0. The application runs fine when I run "python manage.py runserver" on the virtual-env. I have followed all the steps described in the tutorial which Amazon provides, yet without success. Of course I have added my server to the ALLOWED_HOSTS, but I don't think that is the problem.

Is there something that changed in Django 4.0.4 that could've changed things? In my .elasticbeanstalk/config.yml file I have the line "default_platform: Python 3.8 running on 64bit Amazon Linux 2", which should be compatible with Django 4.0.4.

One other thing I have tried is following the same steps from the tutorial again on a new region, with a new application and environment, but this was also not successful.

My .ebextensions/django.config file is the following:

option_settings:
    aws:elasticbeanstalk:container:python:
    WSGIPath: nameofmyproject.wsgi:application

The WSGIPath refers to the wsgi, which is located in nameofmyproject/wsgi.py, which looks like the following:

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'nameofmyproject.settings')

application = get_wsgi_application()

I am not yet using a custom database. I am using the default one provided in a new project, and haven't touched the settings for this one

Back to Top