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

**URL:** <https://forum.djangoproject.com/t/getting-504-issue-when-accessing-django-application-which-deployed-in-local-apache-server/19222>\
**Category:** Deployment\
**Created:** [March 2, 2023, 7:19pm UTC](https://forum.djangoproject.com/t/getting-504-issue-when-accessing-django-application-which-deployed-in-local-apache-server/19222 "2023-03-02T19:19:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sureshchow1](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/sureshchow1/32/11731_2.png) [@sureshchow1](https://forum.djangoproject.com/u/sureshchow1)\
**Post date:** [March 2, 2023, 7:19pm UTC](https://forum.djangoproject.com/t/getting-504-issue-when-accessing-django-application-which-deployed-in-local-apache-server/19222/1 "2023-03-02T19:19:58Z")

</div>

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

```auto
<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

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 3, 2023, 12:54am UTC](https://forum.djangoproject.com/t/getting-504-issue-when-accessing-django-application-which-deployed-in-local-apache-server/19222/2 "2023-03-03T00:54:35Z")

</div>

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](https://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html#virtual-environment-and-python-version)

> 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)

---

<div class="post-metadata">

**Author:** ![sureshchow1](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/sureshchow1/32/11731_2.png) [@sureshchow1](https://forum.djangoproject.com/u/sureshchow1)\
**Post date:** [March 3, 2023, 6:00am UTC](https://forum.djangoproject.com/t/getting-504-issue-when-accessing-django-application-which-deployed-in-local-apache-server/19222/3 "2023-03-03T06:00:47Z")

</div>

I followed below documentation

> **[How To Serve Django Applications with Apache and mod\_wsgi on Ubuntu 14.04 |...](https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04)**
>
> Django is a powerful web framework that can help you get your Python application or website off the ground quickly. Django includes a simplified development …

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

```auto
No where I installed below package which you shared

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

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 3, 2023, 12:32pm UTC](https://forum.djangoproject.com/t/getting-504-issue-when-accessing-django-application-which-deployed-in-local-apache-server/19222/4 "2023-03-03T12:32:28Z")

</div>

> [@sureshchow1](#):
>
> `No where I installed below package which you shared`

Yes, you did:

> [@sureshchow1](#):
>
> sudo apt-get install python3-pip apache2 **libapache2-mod-wsgi-py3**

(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.

---

<div class="post-metadata">

**Author:** ![sureshchow1](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/sureshchow1/32/11731_2.png) [@sureshchow1](https://forum.djangoproject.com/u/sureshchow1)\
**Post date:** [March 3, 2023, 7:01pm UTC](https://forum.djangoproject.com/t/getting-504-issue-when-accessing-django-application-which-deployed-in-local-apache-server/19222/5 "2023-03-03T19:01:12Z")

</div>

> [@KenWhitesell](#):
>
> 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 docu

Will look for latest doc
