Apache2 not loading Django settings.py file properly

I am currently facing an issue where making any changes in settings.py file is not reflecting properly in my project. I have tried deleting the .conf file, adding it again, enabling it and reloading the apache2 server. But somehow it still does not work.

I have an issue with CORS in Django, I made changes to correct it by allowing certain origins to make cross-origin requests:

CORS_ALLOWED_ORIGINS = ['www.test.domain',...]

So I tested it by running the Django server manually using python runserver and it is working fine, not getting any CORS issues

But when I reload the apache2 server or even in this case, make a completely new .conf file and run it via apache2 - it still somehow does not recognize the changes and keeps giving me CORS errors.

I am confused as to what is making this happen - to not reflect any newly made changes. The problem is, now I am not able to reflect these changes with a new configuration as well. So there is no way for me to keep this webserver running without getting CORS errors.

NOTE: Apache has all the required accesses to my Django project - it can access settings.py without any issues.

Tried: Disabling the backend.conf file, deleting it. Creating a new backend.conf file with the following config:

<Directory /home/django_project/main_django_project>
        <Files wsgi.py>
            Require all granted
    WSGIScriptAlias / /home/django_project/main_django_project
    WSGIDaemonProcess app python-path=/home/django_project python-home=/home/venv
    WSGIProcessGroup app

Note: venv has all the required packages to run the django project

Also tried running the same Django project manually with python runserver Didn't see any CORS errors there, but immediately stopped this server and ran the apache2 server again and started seeing the CORS errors.

I also tried one more interesting thing: I set up a logger inside settings.py. It only wrote logs whenever I started the server manually using runserver command, it never wrote logs when it was being run in apache2 webserver which makes me think this settings.py is not being used at all somehow.

Back to Top