[Fixed]-Django; AWS Elastic Beanstalk ERROR: Your WSGIPath refers to a file that does not exist

25👍

[Solution]

1 eb config

2 Change the WSGIPath there from application.py to mysite/wsgi.py

That’s It

👤karan

2👍

I ran into a similar issue, and it seemed to resolve when I put .elasticbeanstalk in the same directory as .ebextensions, rather than having it be a child directory. Then I had to run eb config to fix the wsgi file that it was de facto picking up, and now I have a running app.

2👍

Make sure that .ebextensions isn’t ignored. EB looks for .ignore file (.ebignore by default and if it doesnt exists but .gitignore does, it will use it) and deploy only the files that are not ignored. Had a similar issue with my local_settings.

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-configuration.html#eb-cli3-ebignore

1👍

If you see the following error:

ERROR: Your WSGIPath refers to a file that does not exist.

Note the following:

  1. EC2 (server) instances in EB (platform) run Apache.
  2. Apache finds Python apps according to our WSGIPATH.
  3. By default EB assumes the WSGI file is called application.py.

There are two ways of correcting this.

Option 1: Using environment-specific configuration settings

Run: $ eb config

Find the following config file “.elasticbeanstalk/src-test.env.yml.”
This file doesn’t actually exist locally; EB pulled it so that you can edit it.
If you save changes in this pseudo-file, EB will update the corresponding settings in your env.

If you search for the terms ‘WSGI’ in the file, you should find a config section resembling this:

aws:elasticbeanstalk:container:python:
  NumProcesses: '1'
  NumThreads: '15'
  StaticFiles: /static/=static/
  WSGIPath: application.py

Update the WSGIPath:

 aws:elasticbeanstalk:container:python:
   NumProcesses: '1'
   NumThreads: '15'
   StaticFiles: /static/=static/
   WSGIPath: src/src/wsgi.py #src/src is an example. Do not just c&p.

If you save the file, EB will update the env config automatically.

The advantage to using the $ eb config method to change settings is that you can specify different settings per env.

Option 2: Using global configuration settings

To use this option, create a new file called /.ebextensions/02_python.config:

option_settings:
  "aws:elasticbeanstalk:application:environment":
    DJANGO_SETTINGS_MODULE: “src.settings" #src is an example.
    "PYTHONPATH": "/opt/python/current/app/src:$PYTHONPATH" #src is an example.
  "aws:elasticbeanstalk:container:python":
    WSGIPath: src/src/wsgi.py #src is an example.
    NumProcesses: 3
    NumThreads: 20
  "aws:elasticbeanstalk:container:python:staticfiles":
    "/static/": "www/static/"

What’s happening?

  • DJANGO_SETTINGS_MODULE: "src.settings" – adds the path to the settings module.

  • "PYTHONPATH": "/opt/python/current/app/src:$PYTHONPATH" – updates our PYTHONPATH so Python can find the modules in our application.(Note that the use of the full path is necessary.)

  • WSGIPath: src/src/wsgi.py sets our WSGI Path.

  • NumProcesses: 3 and NumThreads: 20 – updates the number of processes and threads used to run our WSGI application.

  • "/static/": "www/static/" sets our static files path.

Run $ git commit (if necessary) and $ eb deploy to update these settings.

1👍

I did not use console but GUI.

ERROR: Your WSGIPath refers to a file that does not exist.

where could be problem : Creating .zip file

select all : files of your project (not the project folder)

Note : weworkout is my django project (created by django-admin startproject
weworkout)

Right way : select all files

Right way

Wrong way : selecting project folder

wrong way


Also this is the only change you have to do to your django project before uploading

weworkout/.ebextensions/django.config file contains

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: weworkout/wsgi.py

Note : .ebextensions is in same folder as manage.py

0👍

Check if your Django.config file was saved with the correct extension. I had the same issue and the problem was that the file was being saved as a TXT file instead of config file.

Leave a comment