Nginx 502 Bad Gateway - Django


  • Nginx
  • Python
  • Django
    • 13
    • IN
    • Verified
    • Posted byProud
    • TimeMarch 17, 2022, 3:34 p.m.
    • StatusActive

    Snippet Description

    Nginx 502 Bad Gateway - Django.

    Code

       

      Replace Highlighted Code with your config.

       

      1. Check If Gunicorn Service Working Properly

      sudo systemctl servicename restart

       

      sudo systemctl servicename status

       

       a) Check If this is active or not:

       

      servicename.service - gunicorn daemon
         Loaded: loaded (/etc/systemd/system/
      servicename.service; enabled; vendor preset: enabled)
         Active: active (running) since Wed 2022-02-02 08:07:09 UTC; 1 months 12 days ago

       

      If this is active you can go to 2 step

       

      b) If you got any error:

      Most Chances of getting an error of gunicorn installed dir

      First Activate your env:

      source path_to_env/bin/activate

       

      Check gunicorn installed dir:

       which gunicorn

       

      Copy output of this command and open your gunicorn config:

       sudo nano /etc/systemd/system/servicename.service

       

      Now Find the line ExecStart and cut the path which is linked to gunicorn and paste the path you have copied and exit nano

      Restart Service:

      sudo systemctl daemon-reload 

       

      sudo systemctl restart servicename 

      Check status :

      sudo systemctl servicename status

       

      It may be active, it's fixed... 

    Comments

    Related Posts

    Send SMS using Django-Python

    Python Django

    3 Aug. 14, 2022, 4:32 p.m.
    Proud

    Nginx 502 Bad Gateway - Django

    Nginx Python Django

    13 March 17, 2022, 3:34 p.m.
    Proud

    Django Project Updating on Server

    Nginx Python Django

    14 March 17, 2022, 2:17 p.m.
    Proud

    Want to Hire our experts?

    We'll help you to grow your career and growth.
    SignUp Today