504 error when the view loading takes more than 5 s

前端 未结 1 584
有刺的猬
有刺的猬 2020-12-12 06:31

I\'ve got an installation with django-nginx-gunicorn-supervisor-postgresql. In the Django admin, I\'ve got a 504 if the loading of the view takes more than

相关标签:
1条回答
  • 2020-12-12 06:45

    I've found the best way to debug things is to start at Django and work your way up till you figure out what is timing out.

    First, check that Django isn't timing out.

    In one terminal run:

    python manage.py runserver 127.0.0.1:8000
    

    And then in a terminal on the same machine and do:

    wget http://127.0.0.1:8000/<path_to_your_admin_view>
    

    If that works then check to see if Gunicorn is timing out:

    In the Gunicorn config file, change the settings so that it's binding to a local port instead of a socket:

    exec gunicorn -c ${CONF_FILE} ${DJANGO_WSGI_MODULE}:application \
            --name ${NAME} \
            --user=${USER} --group=${GROUP} \
            --log-level=debug \
            --bind=127.0.0.1:8001
            --timeout=90
    

    Make sure you restart supervisor. Then in a terminal on the same machine do:

     wget http://127.0.0.1:8001/<path_to_your_admin_view>
    

    If that works then undo the change to the gunicorn config, restart supervisor and connect directly to nginx to see if it is timing out:

     wget http://127.0.0.1:80/<path_to_your_admin_view>
    

    If this works your problem is likely upstream in a proxy or load balancer.

    0 讨论(0)
提交回复
热议问题