Getting 504 issue when accessing django application which deployed in local apache server

Hi,

I have been deploying the django application in apache in my local ubuntu machine I’ve created a conf file in /etc/apache2/sites-availables

<VirtualHost *:80>

        ServerName myweb.local
        ServerAlias www.myweb.local

        DocumentRoot /home/user/web/MyApp

        ErrorLog ${APACHE_LOG_DIR}/automobile.com_error.log
        CustomLog ${APACHE_LOG_DIR}/automobile.com_access.log combined

        Alias /static /home/user/web/MyApp/static
        <Directory /home/user/web/MyApp/static>
                Require all granted
        </Directory>


        <Directory /home/user/web/MyApp/MyApp>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        WSGIDaemonProcess MyApp python-path=/home/user/web/MyApp python-home=/home/user/web/MyApp/venv/lib/python3.8/site-packages
        WSGIProcessGroup MyApp
        WSGIScriptAlias / /home/user/web/MyApp/MyApp/wsgi.py

</VirtualHost>

And below line in hosts file

127.0.0.1 myweb.local

And I made changes in settings file

DEBUG = False

ALLOWED_HOSTS = [‘myweb.local’]

When I access on Web I can see Below logs in apache error

[Fri Mar 03 00:37:43.587549 2023] [wsgi:error] [pid 29572:tid 140280527312640] [client 127.0.0.1:49954] Timeout when reading response headers from daemon process ‘VahanWeb’: /home/user/web/MyApp/MyApp/wsgi.py
[Fri Mar 03 00:37:46.486766 2023] [wsgi:error] [pid 29573:tid 140280661530368] [client 127.0.0.1:49962] Timeout when reading response headers from daemon process ‘VahanWeb’: /home/user/web/MyApp/MyApp/wsgi.py
[Fri Mar 03 00:38:09.299136 2023] [wsgi:error] [pid 29573:tid 140280653137664] [client 127.0.0.1:35286] Timeout when reading response headers from daemon process ‘VahanWeb’: /home/user/web/MyApp/MyApp/wsgi.py
[Fri Mar 03 00:38:29.179845 2023] [wsgi:error] [pid 29573:tid 140280769890048] [client 127.0.0.1:34094] Timeout when reading response headers from daemon process ‘VahanWeb’: /home/user/web/MyApp/MyApp/wsgi.py

The most common mistake I see with trying to run Django under Apache is attempting to use a different version of python for the application than what was used to compile the mod_wsgi interface.

From: Virtual Environments — mod_wsgi 4.9.2 documentation

When using a Python virtual environment with mod_wsgi, it is very important that it has been created using the same Python installation that mod_wsgi was originally compiled for. It is not possible to use a Python virtual environment to force mod_wsgi to use a different Python version, or even a different Python installation.

(more details follow on that page)

I followed below documentation

And installed ```
sudo apt-get install python3-pip apache2 libapache2-mod-wsgi-py3

No where I installed below package which you shared

https://modwsgi.readthedocs.io/en/develop/installation.html

Yes, you did:

(Emphasis added.)

I’ll also point out that that page you’re referencing is for an extremely old version of Ubuntu. I’m hoping you’re not still running a server on Ubuntu 14.04. If not, you need to find more current documentation.

Will look for latest doc