504 Таймаут шлюза Шлюз не получил своевременный ответ от вышестоящего сервера или приложения.

Когда я развернул свой проект django на сервере ubuntu, я получил эту ошибку на веб-странице:

Gateway Timeout
The gateway did not receive a timely response from the upstream server or application.

Мой журнал ошибок apache:

[wsgi:error] [pid 395259:tid 139814842119936] [client 188.211.36.201:43695] Timeout when reading response headers from daemon process 'example.com': /home/myuser/apartment/apartment/wsgi.py
[wsgi:error] [pid 395259:tid 139814850512640] [client 178.63.87.197:38586] Timeout when reading response headers from daemon process 'example.com': /home/myuser/apartment/apartment/wsgi.py

Журнал ошибок Apache показывает:

Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f2936b06c40 (most recent call first):
<no Python frame>
Python path configuration:
  PYTHONHOME = '/home/myuser/envb9/lib/python3.8/site-packages'
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/home/myuser/envb9/lib/python3.8/site-packages'
  sys.base_exec_prefix = '/home/myuser/envb9/lib/python3.8/site-packages'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/home/myuser/envb9/lib/python3.8/site-packages'
  sys.exec_prefix = '/home/myuser/envb9/lib/python3.8/site-packages'
  sys.path = [
    '/home/myuser/envb9/lib/python3.8/site-packages/lib/python38.zip',
    '/home/myuser/envb9/lib/python3.8/site-packages/lib/python3.8',
    '/home/myuser/envb9/lib/python3.8/site-packages/lib/python3.8/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f2936b06c40 (most recent call first):
<no Python frame>

/etc/apache2/sites-available/apartment.conf is:

<VirtualHost *:80>
    ServerName  example.com
    ServerAdmin webmaster@example.com
    DocumentRoot /home/myuser/apartment

    Alias /static/  /home/myuser/apartment/static/
    Alias /media/  /home/myuser/apartment/media/

    WSGIScriptAlias /   /home/myuser/apartment/apartment/wsgi.py
    WSGIDaemonProcess example.com python-path=/home/myuser/apartment python-home=/home/myuser/envb9/lib/python3.8/site-packages
#   WSGIDaemonProcess example.com python-path=/home/myuser/apartment python-home=/home/myuser/envb9/
#    WSGIDaemonProcess   example.com  python-path=/home/myuser/apartment  python-home=/home/myuser/envb9
#    WSGIPythonPath /home/myuser/apartment:/home/myuser/lib/python3.8/site-packages
    WSGIProcessGroup example.com


        <Directory /home/myuser/apartment/static/>
                Require all granted
        </Directory>

        <Directory /home/myuser/apartment/media/>
                Require all granted
        </Directory>

        <Directory /home/myuser/apartment/apartment>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        LogLevel info

    #       WSGIApplicationGroup %{GLOBAL}
    # PROJECT_NAME is used to seperate the log files of this application
    ErrorLog    /home/myuser/error.log
    CustomLog   /home/myuser/access.log combined
</VirtualHost>

/home/myuser/apartment/apartment/wsgi.py is:

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'apartment.settings')
application = get_wsgi_application()
Вернуться на верх