[{"data":1,"prerenderedAt":8753},["ShallowReactive",2],{"article-production-checklist-django-production-checklist-everything-you-must-do":3,"article-list":983},{"id":4,"title":5,"body":6,"category":967,"description":968,"extension":969,"meta":970,"navigation":54,"path":971,"priority":972,"related":973,"role":974,"section":975,"seo":976,"stem":977,"tags":978,"__hash__":982},"articles\u002Fdjango-production-checklist-everything-you-must-do.md","Django Production Checklist (Everything You Must Do Before Going Live)",{"type":7,"value":8,"toc":932},"minimark",[9,13,16,32,35,38,43,111,113,117,122,148,151,155,184,188,191,199,201,205,222,240,248,252,261,267,269,273,284,303,309,311,315,326,341,343,347,350,356,361,366,374,388,392,402,417,420,428,432,439,484,487,489,493,528,531,533,537,540,566,568,572,575,603,606,610,613,624,632,636,638,644,647,650,654,657,712,714,718,720,724,727,731,734,738,741,745,748,752,755,757,817,819,823,845,847,851,855,858,861,864,868,871,879,883,886,900,902,906,909,920,922,925,928],[10,11,12],"p",{},"Before you deploy your Django app to production, there are several critical steps you must complete.",[10,14,15],{},"If you skip these, you risk:",[17,18,19,23,26,29],"ul",{},[20,21,22],"li",{},"Broken static files",[20,24,25],{},"Security vulnerabilities",[20,27,28],{},"Performance issues",[20,30,31],{},"Downtime",[10,33,34],{},"This checklist ensures your app is secure, stable, and production-ready.",[36,37],"hr",{},[39,40,42],"h2",{"id":41},"quick-checklist-overview","⚡ Quick Checklist (Overview)",[17,44,47,57,63,69,75,81,87,93,99,105],{"className":45},[46],"contains-task-list",[20,48,51,56],{"className":49},[50],"task-list-item",[52,53],"input",{"disabled":54,"type":55},true,"checkbox"," DEBUG disabled",[20,58,60,62],{"className":59},[50],[52,61],{"disabled":54,"type":55}," ALLOWED_HOSTS configured",[20,64,66,68],{"className":65},[50],[52,67],{"disabled":54,"type":55}," Static files working",[20,70,72,74],{"className":71},[50],[52,73],{"disabled":54,"type":55}," Media files working",[20,76,78,80],{"className":77},[50],[52,79],{"disabled":54,"type":55}," Gunicorn configured",[20,82,84,86],{"className":83},[50],[52,85],{"disabled":54,"type":55}," Nginx configured",[20,88,90,92],{"className":89},[50],[52,91],{"disabled":54,"type":55}," Database configured (PostgreSQL recommended)",[20,94,96,98],{"className":95},[50],[52,97],{"disabled":54,"type":55}," HTTPS enabled",[20,100,102,104],{"className":101},[50],[52,103],{"disabled":54,"type":55}," Environment variables secured",[20,106,108,110],{"className":107},[50],[52,109],{"disabled":54,"type":55}," Permissions set correctly",[36,112],{},[39,114,116],{"id":115},"_1-django-settings-critical","🧠 1. Django Settings (Critical)",[118,119,121],"h3",{"id":120},"disable-debug","Disable DEBUG",[123,124,129],"pre",{"className":125,"code":126,"language":127,"meta":128,"style":128},"language-python shiki shiki-themes github-light github-dark","DEBUG = False\n","python","",[130,131,132],"code",{"__ignoreMap":128},[133,134,137,141,145],"span",{"class":135,"line":136},"line",1,[133,138,140],{"class":139},"sj4cs","DEBUG",[133,142,144],{"class":143},"szBVR"," =",[133,146,147],{"class":139}," False\n",[10,149,150],{},"👉 Leaving this enabled is a major security risk",[118,152,154],{"id":153},"set-allowed_hosts","Set ALLOWED_HOSTS",[123,156,158],{"className":125,"code":157,"language":127,"meta":128,"style":128},"ALLOWED_HOSTS = ['your-domain.com', 'your-server-ip']\n",[130,159,160],{"__ignoreMap":128},[133,161,162,165,167,171,175,178,181],{"class":135,"line":136},[133,163,164],{"class":139},"ALLOWED_HOSTS",[133,166,144],{"class":143},[133,168,170],{"class":169},"sVt8B"," [",[133,172,174],{"class":173},"sZZnC","'your-domain.com'",[133,176,177],{"class":169},", ",[133,179,180],{"class":173},"'your-server-ip'",[133,182,183],{"class":169},"]\n",[118,185,187],{"id":186},"use-environment-variables","Use environment variables",[10,189,190],{},"Never hardcode:",[17,192,193,196],{},[20,194,195],{},"Secret keys",[20,197,198],{},"Database credentials",[36,200],{},[39,202,204],{"id":203},"_2-static-files-setup","🧱 2. Static Files Setup",[17,206,207,213,219],{},[20,208,209,210],{},"Set ",[130,211,212],{},"STATIC_ROOT",[20,214,215,216],{},"Run ",[130,217,218],{},"collectstatic",[20,220,221],{},"Configure Nginx",[123,223,227],{"className":224,"code":225,"language":226,"meta":128,"style":128},"language-bash shiki shiki-themes github-light github-dark","python manage.py collectstatic\n","bash",[130,228,229],{"__ignoreMap":128},[133,230,231,234,237],{"class":135,"line":136},[133,232,127],{"class":233},"sScJk",[133,235,236],{"class":173}," manage.py",[133,238,239],{"class":173}," collectstatic\n",[10,241,242,243],{},"👉 Full guide: ",[244,245,247],"a",{"href":246},"\u002Ffix-issues\u002Fdjango-static-files-not-loading-in-production","Django static files not loading",[39,249,251],{"id":250},"_3-media-files-setup","🧩 3. Media Files Setup",[17,253,254,259],{},[20,255,209,256],{},[130,257,258],{},"MEDIA_ROOT",[20,260,221],{},[10,262,242,263],{},[244,264,266],{"href":265},"\u002Ffix-issues\u002Fdjango-media-files-not-serving-uploads-broken","Django media files not serving",[36,268],{},[39,270,272],{"id":271},"️-4-application-server-gunicorn","⚙️ 4. Application Server (Gunicorn)",[17,274,275,278,281],{},[20,276,277],{},"Install Gunicorn",[20,279,280],{},"Configure systemd",[20,282,283],{},"Ensure it runs on boot",[123,285,287],{"className":224,"code":286,"language":226,"meta":128,"style":128},"sudo systemctl enable gunicorn\n",[130,288,289],{"__ignoreMap":128},[133,290,291,294,297,300],{"class":135,"line":136},[133,292,293],{"class":233},"sudo",[133,295,296],{"class":173}," systemctl",[133,298,299],{"class":173}," enable",[133,301,302],{"class":173}," gunicorn\n",[10,304,242,305],{},[244,306,308],{"href":307},"\u002Fdeploy\u002Fdeploy-django-with-nginx-gunicorn-step-by-step","Deploy Django with Nginx + Gunicorn",[36,310],{},[39,312,314],{"id":313},"_5-web-server-nginx","🌐 5. Web Server (Nginx)",[17,316,317,320,323],{},[20,318,319],{},"Reverse proxy to Gunicorn",[20,321,322],{},"Serve static and media files",[20,324,325],{},"Validate config",[123,327,329],{"className":224,"code":328,"language":226,"meta":128,"style":128},"sudo nginx -t\n",[130,330,331],{"__ignoreMap":128},[133,332,333,335,338],{"class":135,"line":136},[133,334,293],{"class":233},[133,336,337],{"class":173}," nginx",[133,339,340],{"class":139}," -t\n",[36,342],{},[39,344,346],{"id":345},"️-6-database-production-setup","🗄️ 6. Database (Production Setup)",[10,348,349],{},"Do NOT use SQLite in production.",[10,351,352],{},[353,354,355],"strong",{},"Use:",[17,357,358],{},[20,359,360],{},"PostgreSQL (recommended)",[10,362,363],{},[353,364,365],{},"Check:",[17,367,368,371],{},[20,369,370],{},"Migrations applied",[20,372,373],{},"Database accessible",[123,375,377],{"className":224,"code":376,"language":226,"meta":128,"style":128},"python manage.py migrate\n",[130,378,379],{"__ignoreMap":128},[133,380,381,383,385],{"class":135,"line":136},[133,382,127],{"class":233},[133,384,236],{"class":173},[133,386,387],{"class":173}," migrate\n",[39,389,391],{"id":390},"_7-https-required","🔐 7. HTTPS (Required)",[10,393,394,395,401],{},"Use ",[244,396,400],{"href":397,"rel":398},"https:\u002F\u002Fletsencrypt.org\u002F",[399],"nofollow","Let's Encrypt"," for free SSL certificates.",[123,403,405],{"className":224,"code":404,"language":226,"meta":128,"style":128},"sudo certbot --nginx\n",[130,406,407],{"__ignoreMap":128},[133,408,409,411,414],{"class":135,"line":136},[133,410,293],{"class":233},[133,412,413],{"class":173}," certbot",[133,415,416],{"class":139}," --nginx\n",[10,418,419],{},"Also enable:",[17,421,422,425],{},[20,423,424],{},"Secure cookies",[20,426,427],{},"HSTS headers",[39,429,431],{"id":430},"_8-security-settings","🔒 8. Security Settings",[10,433,434,435,438],{},"In ",[130,436,437],{},"settings.py",":",[123,440,442],{"className":125,"code":441,"language":127,"meta":128,"style":128},"SECURE_BROWSER_XSS_FILTER = True\nSECURE_CONTENT_TYPE_NOSNIFF = True\nCSRF_COOKIE_SECURE = True\nSESSION_COOKIE_SECURE = True\n",[130,443,444,454,464,474],{"__ignoreMap":128},[133,445,446,449,451],{"class":135,"line":136},[133,447,448],{"class":139},"SECURE_BROWSER_XSS_FILTER",[133,450,144],{"class":143},[133,452,453],{"class":139}," True\n",[133,455,457,460,462],{"class":135,"line":456},2,[133,458,459],{"class":139},"SECURE_CONTENT_TYPE_NOSNIFF",[133,461,144],{"class":143},[133,463,453],{"class":139},[133,465,467,470,472],{"class":135,"line":466},3,[133,468,469],{"class":139},"CSRF_COOKIE_SECURE",[133,471,144],{"class":143},[133,473,453],{"class":139},[133,475,477,480,482],{"class":135,"line":476},4,[133,478,479],{"class":139},"SESSION_COOKIE_SECURE",[133,481,144],{"class":143},[133,483,453],{"class":139},[10,485,486],{},"👉 Prevents common vulnerabilities",[36,488],{},[39,490,492],{"id":491},"_9-file-permissions","📁 9. File Permissions",[123,494,496],{"className":224,"code":495,"language":226,"meta":128,"style":128},"sudo chown -R www-data:www-data \u002Fvar\u002Fwww\u002Fmyproject\nsudo chmod -R 755 \u002Fvar\u002Fwww\u002Fmyproject\n",[130,497,498,514],{"__ignoreMap":128},[133,499,500,502,505,508,511],{"class":135,"line":136},[133,501,293],{"class":233},[133,503,504],{"class":173}," chown",[133,506,507],{"class":139}," -R",[133,509,510],{"class":173}," www-data:www-data",[133,512,513],{"class":173}," \u002Fvar\u002Fwww\u002Fmyproject\n",[133,515,516,518,521,523,526],{"class":135,"line":456},[133,517,293],{"class":233},[133,519,520],{"class":173}," chmod",[133,522,507],{"class":139},[133,524,525],{"class":139}," 755",[133,527,513],{"class":173},[10,529,530],{},"👉 Prevents access and runtime errors",[36,532],{},[39,534,536],{"id":535},"_10-process-management","🔄 10. Process Management",[10,538,539],{},"Ensure services restart automatically:",[123,541,543],{"className":224,"code":542,"language":226,"meta":128,"style":128},"sudo systemctl enable gunicorn\nsudo systemctl enable nginx\n",[130,544,545,555],{"__ignoreMap":128},[133,546,547,549,551,553],{"class":135,"line":136},[133,548,293],{"class":233},[133,550,296],{"class":173},[133,552,299],{"class":173},[133,554,302],{"class":173},[133,556,557,559,561,563],{"class":135,"line":456},[133,558,293],{"class":233},[133,560,296],{"class":173},[133,562,299],{"class":173},[133,564,565],{"class":173}," nginx\n",[36,567],{},[39,569,571],{"id":570},"_11-logging-debugging","🧪 11. Logging & Debugging",[10,573,574],{},"Check logs:",[123,576,578],{"className":224,"code":577,"language":226,"meta":128,"style":128},"journalctl -u gunicorn\nsudo tail -f \u002Fvar\u002Flog\u002Fnginx\u002Ferror.log\n",[130,579,580,590],{"__ignoreMap":128},[133,581,582,585,588],{"class":135,"line":136},[133,583,584],{"class":233},"journalctl",[133,586,587],{"class":139}," -u",[133,589,302],{"class":173},[133,591,592,594,597,600],{"class":135,"line":456},[133,593,293],{"class":233},[133,595,596],{"class":173}," tail",[133,598,599],{"class":139}," -f",[133,601,602],{"class":173}," \u002Fvar\u002Flog\u002Fnginx\u002Ferror.log\n",[10,604,605],{},"👉 Essential for troubleshooting",[39,607,609],{"id":608},"_12-performance-basics","⚡ 12. Performance Basics",[10,611,612],{},"Set Gunicorn workers:",[123,614,618],{"className":615,"code":616,"language":617,"meta":128,"style":128},"language-console shiki shiki-themes github-light github-dark","workers = (2 × CPU cores) + 1\n","console",[130,619,620],{"__ignoreMap":128},[133,621,622],{"class":135,"line":136},[133,623,616],{},[17,625,626,629],{},[20,627,628],{},"Enable gzip in Nginx",[20,630,631],{},"Use caching headers",[39,633,635],{"id":634},"_13-environment-separation","🧠 13. Environment Separation",[10,637,355],{},[10,639,640,643],{},[130,641,642],{},".env"," files",[10,645,646],{},"Different settings for dev\u002Fprod",[10,648,649],{},"👉 Avoids configuration mistakes",[39,651,653],{"id":652},"_14-deployment-workflow","🔁 14. Deployment Workflow",[10,655,656],{},"Before every deployment:",[123,658,660],{"className":224,"code":659,"language":226,"meta":128,"style":128},"git pull\npip install -r requirements.txt\npython manage.py migrate\npython manage.py collectstatic\nsudo systemctl restart gunicorn\n",[130,661,662,670,684,692,700],{"__ignoreMap":128},[133,663,664,667],{"class":135,"line":136},[133,665,666],{"class":233},"git",[133,668,669],{"class":173}," pull\n",[133,671,672,675,678,681],{"class":135,"line":456},[133,673,674],{"class":233},"pip",[133,676,677],{"class":173}," install",[133,679,680],{"class":139}," -r",[133,682,683],{"class":173}," requirements.txt\n",[133,685,686,688,690],{"class":135,"line":466},[133,687,127],{"class":233},[133,689,236],{"class":173},[133,691,387],{"class":173},[133,693,694,696,698],{"class":135,"line":476},[133,695,127],{"class":233},[133,697,236],{"class":173},[133,699,239],{"class":173},[133,701,703,705,707,710],{"class":135,"line":702},5,[133,704,293],{"class":233},[133,706,296],{"class":173},[133,708,709],{"class":173}," restart",[133,711,302],{"class":173},[36,713],{},[39,715,717],{"id":716},"common-mistakes","🔥 Common Mistakes",[36,719],{},[118,721,723],{"id":722},"debug-left-on","🔴 DEBUG left on",[10,725,726],{},"👉 Security risk",[118,728,730],{"id":729},"static-files-not-configured","🔴 Static files not configured",[10,732,733],{},"👉 Broken UI",[118,735,737],{"id":736},"no-https","🔴 No HTTPS",[10,739,740],{},"👉 Insecure site",[118,742,744],{"id":743},"wrong-permissions","🔴 Wrong permissions",[10,746,747],{},"👉 Runtime errors",[118,749,751],{"id":750},"no-process-restart","🔴 No process restart",[10,753,754],{},"👉 Downtime after reboot",[36,756],{},[758,759,762,765],"article-callout",{"title":760,"type":761},"Use this checklist with the core implementation guides","success",[10,763,764],{},"Work through the full stack in order:",[17,766,767,771,777,783,789,795,801,806,811],{},[20,768,769],{},[244,770,308],{"href":307},[20,772,773],{},[244,774,776],{"href":775},"\u002Fdeploy\u002Fhow-to-set-up-https-for-django-nginx-lets-encrypt","Set up HTTPS for Django",[20,778,779],{},[244,780,782],{"href":781},"\u002Fdeploy\u002Fdjango-docker-production-setup-complete-guide","Deploy Django with Docker",[20,784,785],{},[244,786,788],{"href":787},"\u002Ffix-issues\u002Ffix-django-502-bad-gateway-step-by-step-guide","Fix Django 502 Bad Gateway",[20,790,791],{},[244,792,794],{"href":793},"\u002Ffix-issues\u002Ffix-nginx-not-connecting-to-gunicorn-connection-refused","Fix Nginx not connecting to Gunicorn",[20,796,797],{},[244,798,800],{"href":799},"\u002Ffix-issues\u002Fgunicorn-socket-permission-denied-fix-guide","Fix Gunicorn socket permission denied",[20,802,803],{},[244,804,805],{"href":246},"Fix Django static files",[20,807,808],{},[244,809,810],{"href":265},"Fix Django media files",[20,812,813],{},[244,814,816],{"href":815},"\u002Foptimize\u002Fzero-downtime-django-deployment-gunicorn-reload-strategy","Plan zero-downtime Gunicorn reloads",[36,818],{},[39,820,822],{"id":821},"related-guides","🔗 Related Guides",[17,824,825,829,833,837,841],{},[20,826,827],{},[244,828,308],{"href":307},[20,830,831],{},[244,832,776],{"href":775},[20,834,835],{},[244,836,788],{"href":787},[20,838,839],{},[244,840,247],{"href":246},[20,842,843],{},[244,844,266],{"href":265},[36,846],{},[39,848,850],{"id":849},"faq","❓ FAQ",[118,852,854],{"id":853},"can-i-use-sqlite-in-production","Can I use SQLite in production?",[10,856,857],{},"Not recommended.",[10,859,860],{},"Use PostgreSQL for:",[10,862,863],{},"Performance\nReliability",[118,865,867],{"id":866},"do-i-need-docker","Do I need Docker?",[10,869,870],{},"Optional—but useful for:",[17,872,873,876],{},[20,874,875],{},"Consistency",[20,877,878],{},"Easier deployments",[118,880,882],{"id":881},"how-do-i-know-everything-works","How do I know everything works?",[10,884,885],{},"Use this checklist + test:",[17,887,888,891,894,897],{},[20,889,890],{},"Homepage",[20,892,893],{},"Admin panel",[20,895,896],{},"Static files",[20,898,899],{},"Uploads",[36,901],{},[39,903,905],{"id":904},"final-takeaway","🎯 Final takeaway",[10,907,908],{},"A production-ready Django app requires:",[17,910,911,914,917],{},[20,912,913],{},"Correct configuration",[20,915,916],{},"Proper security",[20,918,919],{},"Reliable deployment setup",[36,921],{},[10,923,924],{},"If you deploy often…",[10,926,927],{},"Using a repeatable, pre-tested system saves time and prevents errors.",[929,930,931],"style",{},"html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}",{"title":128,"searchDepth":466,"depth":466,"links":933},[934,935,940,941,942,943,944,945,946,947,948,949,950,951,952,953,960,961,966],{"id":41,"depth":456,"text":42},{"id":115,"depth":456,"text":116,"children":936},[937,938,939],{"id":120,"depth":466,"text":121},{"id":153,"depth":466,"text":154},{"id":186,"depth":466,"text":187},{"id":203,"depth":456,"text":204},{"id":250,"depth":456,"text":251},{"id":271,"depth":456,"text":272},{"id":313,"depth":456,"text":314},{"id":345,"depth":456,"text":346},{"id":390,"depth":456,"text":391},{"id":430,"depth":456,"text":431},{"id":491,"depth":456,"text":492},{"id":535,"depth":456,"text":536},{"id":570,"depth":456,"text":571},{"id":608,"depth":456,"text":609},{"id":634,"depth":456,"text":635},{"id":652,"depth":456,"text":653},{"id":716,"depth":456,"text":717,"children":954},[955,956,957,958,959],{"id":722,"depth":466,"text":723},{"id":729,"depth":466,"text":730},{"id":736,"depth":466,"text":737},{"id":743,"depth":466,"text":744},{"id":750,"depth":466,"text":751},{"id":821,"depth":456,"text":822},{"id":849,"depth":456,"text":850,"children":962},[963,964,965],{"id":853,"depth":466,"text":854},{"id":866,"depth":466,"text":867},{"id":881,"depth":466,"text":882},{"id":904,"depth":456,"text":905},"Checklist","A comprehensive checklist for deploying a Django application to production. Ensure your app is secure, performant, and reliable with these essential pre-launch steps.","md",{},"\u002Fdjango-production-checklist-everything-you-must-do","1",[307,775,246,265,787],"authority","production-checklist",{"title":5,"description":968},"django-production-checklist-everything-you-must-do",[979,980,981],"django","production","checklist","HAvJJttYgOvzQt7d0GC8unVCv6c1pu_CCCkwZhj-IaA",[984,2042,3054,3756,4453,5188,5839,6641,7410,8052],{"id":985,"title":986,"body":987,"category":2029,"description":2030,"extension":969,"meta":2031,"navigation":54,"path":2032,"priority":2033,"related":2034,"role":2035,"section":2036,"seo":2037,"stem":2038,"tags":2039,"__hash__":2041},"articles\u002Fdjango-docker-production-setup-complete-guide.md","Deploy Django with Docker (Production Setup – Complete Guide)",{"type":7,"value":988,"toc":1994},[989,992,1006,1009,1011,1015,1018,1021,1036,1038,1042,1049,1052,1061,1063,1067,1070,1078,1082,1085,1145,1149,1215,1222,1441,1445,1447,1456,1459,1558,1562,1566,1619,1623,1646,1650,1668,1672,1675,1684,1687,1689,1693,1695,1699,1702,1720,1722,1728,1732,1734,1757,1761,1773,1777,1791,1795,1799,1813,1817,1839,1842,1880,1883,1885,1900,1902,1904,1920,1922,1924,1928,1931,1935,1945,1949,1952,1956,1959,1963,1966,1968,1970,1973,1984,1986,1988,1991],[10,990,991],{},"This guide shows you how to deploy a Django application in production using:",[17,993,994,997,1000,1003],{},[20,995,996],{},"Docker",[20,998,999],{},"Docker Compose",[20,1001,1002],{},"Nginx (reverse proxy)",[20,1004,1005],{},"Gunicorn",[10,1007,1008],{},"By the end, you’ll have a reproducible, production-ready deployment.",[36,1010],{},[39,1012,1014],{"id":1013},"quick-overview","⚡ Quick Overview",[10,1016,1017],{},"You will:",[10,1019,1020],{},"Containerize your Django app",[1022,1023,1024,1027,1030,1033],"ol",{},[20,1025,1026],{},"Add Gunicorn",[20,1028,1029],{},"Configure Docker Compose",[20,1031,1032],{},"Add Nginx as reverse proxy",[20,1034,1035],{},"Serve static files correctly",[36,1037],{},[39,1039,1041],{"id":1040},"architecture-overview","🧠 Architecture Overview",[10,1043,1044],{},[1045,1046],"img",{"alt":1047,"src":1048},"Client Nginx container Django Gunicorn container flow","\u002Fimages\u002FClient-Nginx-container-Django-Gunicorn-container.png",[10,1050,1051],{},"Flow:",[123,1053,1055],{"className":615,"code":1054,"language":617,"meta":128,"style":128},"Client → Nginx (container) → Django (Gunicorn container)\n",[130,1056,1057],{"__ignoreMap":128},[133,1058,1059],{"class":135,"line":136},[133,1060,1054],{},[36,1062],{},[39,1064,1066],{"id":1065},"prerequisites","🧱 Prerequisites",[10,1068,1069],{},"Server (Ubuntu recommended)",[17,1071,1072,1075],{},[20,1073,1074],{},"Docker installed",[20,1076,1077],{},"Docker Compose installed",[118,1079,1081],{"id":1080},"_1-project-structure","1. Project Structure",[10,1083,1084],{},"Create:",[123,1086,1088],{"className":224,"code":1087,"language":226,"meta":128,"style":128},"myproject\u002F\n├── app\u002F\n├── docker-compose.yml\n├── Dockerfile\n├── nginx\u002F\n│   └── default.conf\n└── .env\n\n",[130,1089,1090,1095,1103,1110,1117,1124,1136],{"__ignoreMap":128},[133,1091,1092],{"class":135,"line":136},[133,1093,1094],{"class":233},"myproject\u002F\n",[133,1096,1097,1100],{"class":135,"line":456},[133,1098,1099],{"class":233},"├──",[133,1101,1102],{"class":173}," app\u002F\n",[133,1104,1105,1107],{"class":135,"line":466},[133,1106,1099],{"class":233},[133,1108,1109],{"class":173}," docker-compose.yml\n",[133,1111,1112,1114],{"class":135,"line":476},[133,1113,1099],{"class":233},[133,1115,1116],{"class":173}," Dockerfile\n",[133,1118,1119,1121],{"class":135,"line":702},[133,1120,1099],{"class":233},[133,1122,1123],{"class":173}," nginx\u002F\n",[133,1125,1127,1130,1133],{"class":135,"line":1126},6,[133,1128,1129],{"class":233},"│",[133,1131,1132],{"class":173},"   └──",[133,1134,1135],{"class":173}," default.conf\n",[133,1137,1139,1142],{"class":135,"line":1138},7,[133,1140,1141],{"class":233},"└──",[133,1143,1144],{"class":173}," .env\n",[118,1146,1148],{"id":1147},"_2-create-dockerfile","2. Create Dockerfile",[123,1150,1154],{"className":1151,"code":1152,"language":1153,"meta":128,"style":128},"language-dockerfile shiki shiki-themes github-light github-dark","FROM python:3.11-slim\nWORKDIR \u002Fapp\nCOPY app\u002F \u002Fapp\u002F\nRUN pip install --no-cache-dir django gunicorn\nCMD [\"gunicorn\", \"--bind\", \"0.0.0.0:8000\", \"myproject.wsgi:application\"]\n","dockerfile",[130,1155,1156,1164,1172,1180,1188],{"__ignoreMap":128},[133,1157,1158,1161],{"class":135,"line":136},[133,1159,1160],{"class":143},"FROM",[133,1162,1163],{"class":169}," python:3.11-slim\n",[133,1165,1166,1169],{"class":135,"line":456},[133,1167,1168],{"class":143},"WORKDIR",[133,1170,1171],{"class":169}," \u002Fapp\n",[133,1173,1174,1177],{"class":135,"line":466},[133,1175,1176],{"class":143},"COPY",[133,1178,1179],{"class":169}," app\u002F \u002Fapp\u002F\n",[133,1181,1182,1185],{"class":135,"line":476},[133,1183,1184],{"class":143},"RUN",[133,1186,1187],{"class":169}," pip install --no-cache-dir django gunicorn\n",[133,1189,1190,1193,1195,1198,1200,1203,1205,1208,1210,1213],{"class":135,"line":702},[133,1191,1192],{"class":143},"CMD",[133,1194,170],{"class":169},[133,1196,1197],{"class":173},"\"gunicorn\"",[133,1199,177],{"class":169},[133,1201,1202],{"class":173},"\"--bind\"",[133,1204,177],{"class":169},[133,1206,1207],{"class":173},"\"0.0.0.0:8000\"",[133,1209,177],{"class":169},[133,1211,1212],{"class":173},"\"myproject.wsgi:application\"",[133,1214,183],{"class":169},[118,1216,1218,1219],{"id":1217},"_3-create-docker-composeyml","3. Create ",[130,1220,1221],{},"docker-compose.yml",[123,1223,1227],{"className":1224,"code":1225,"language":1226,"meta":128,"style":128},"language-yaml shiki shiki-themes github-light github-dark","version: '3'\n\nservices:\n  web:\n    build: .\n    container_name: django_app\n    command: gunicorn myproject.wsgi:application --bind 0.0.0.0:8000\n    volumes:\n      - .\u002Fapp:\u002Fapp\n      - static_volume:\u002Fapp\u002Fstatic\n    expose:\n      - 8000\n\n  nginx:\n    image: nginx:latest\n    container_name: nginx\n    ports:\n      - \"80:80\"\n    volumes:\n      - .\u002Fnginx\u002Fdefault.conf:\u002Fetc\u002Fnginx\u002Fconf.d\u002Fdefault.conf\n      - static_volume:\u002Fapp\u002Fstatic\n    depends_on:\n      - web\n\nvolumes:\n  static_volume:\n","yaml",[130,1228,1229,1241,1246,1254,1261,1271,1281,1291,1299,1308,1316,1324,1332,1337,1345,1356,1366,1374,1382,1389,1397,1404,1412,1420,1425,1433],{"__ignoreMap":128},[133,1230,1231,1235,1238],{"class":135,"line":136},[133,1232,1234],{"class":1233},"s9eBZ","version",[133,1236,1237],{"class":169},": ",[133,1239,1240],{"class":173},"'3'\n",[133,1242,1243],{"class":135,"line":456},[133,1244,1245],{"emptyLinePlaceholder":54},"\n",[133,1247,1248,1251],{"class":135,"line":466},[133,1249,1250],{"class":1233},"services",[133,1252,1253],{"class":169},":\n",[133,1255,1256,1259],{"class":135,"line":476},[133,1257,1258],{"class":1233},"  web",[133,1260,1253],{"class":169},[133,1262,1263,1266,1268],{"class":135,"line":702},[133,1264,1265],{"class":1233},"    build",[133,1267,1237],{"class":169},[133,1269,1270],{"class":139},".\n",[133,1272,1273,1276,1278],{"class":135,"line":1126},[133,1274,1275],{"class":1233},"    container_name",[133,1277,1237],{"class":169},[133,1279,1280],{"class":173},"django_app\n",[133,1282,1283,1286,1288],{"class":135,"line":1138},[133,1284,1285],{"class":1233},"    command",[133,1287,1237],{"class":169},[133,1289,1290],{"class":173},"gunicorn myproject.wsgi:application --bind 0.0.0.0:8000\n",[133,1292,1294,1297],{"class":135,"line":1293},8,[133,1295,1296],{"class":1233},"    volumes",[133,1298,1253],{"class":169},[133,1300,1302,1305],{"class":135,"line":1301},9,[133,1303,1304],{"class":169},"      - ",[133,1306,1307],{"class":173},".\u002Fapp:\u002Fapp\n",[133,1309,1311,1313],{"class":135,"line":1310},10,[133,1312,1304],{"class":169},[133,1314,1315],{"class":173},"static_volume:\u002Fapp\u002Fstatic\n",[133,1317,1319,1322],{"class":135,"line":1318},11,[133,1320,1321],{"class":1233},"    expose",[133,1323,1253],{"class":169},[133,1325,1327,1329],{"class":135,"line":1326},12,[133,1328,1304],{"class":169},[133,1330,1331],{"class":139},"8000\n",[133,1333,1335],{"class":135,"line":1334},13,[133,1336,1245],{"emptyLinePlaceholder":54},[133,1338,1340,1343],{"class":135,"line":1339},14,[133,1341,1342],{"class":1233},"  nginx",[133,1344,1253],{"class":169},[133,1346,1348,1351,1353],{"class":135,"line":1347},15,[133,1349,1350],{"class":1233},"    image",[133,1352,1237],{"class":169},[133,1354,1355],{"class":173},"nginx:latest\n",[133,1357,1359,1361,1363],{"class":135,"line":1358},16,[133,1360,1275],{"class":1233},[133,1362,1237],{"class":169},[133,1364,1365],{"class":173},"nginx\n",[133,1367,1369,1372],{"class":135,"line":1368},17,[133,1370,1371],{"class":1233},"    ports",[133,1373,1253],{"class":169},[133,1375,1377,1379],{"class":135,"line":1376},18,[133,1378,1304],{"class":169},[133,1380,1381],{"class":173},"\"80:80\"\n",[133,1383,1385,1387],{"class":135,"line":1384},19,[133,1386,1296],{"class":1233},[133,1388,1253],{"class":169},[133,1390,1392,1394],{"class":135,"line":1391},20,[133,1393,1304],{"class":169},[133,1395,1396],{"class":173},".\u002Fnginx\u002Fdefault.conf:\u002Fetc\u002Fnginx\u002Fconf.d\u002Fdefault.conf\n",[133,1398,1400,1402],{"class":135,"line":1399},21,[133,1401,1304],{"class":169},[133,1403,1315],{"class":173},[133,1405,1407,1410],{"class":135,"line":1406},22,[133,1408,1409],{"class":1233},"    depends_on",[133,1411,1253],{"class":169},[133,1413,1415,1417],{"class":135,"line":1414},23,[133,1416,1304],{"class":169},[133,1418,1419],{"class":173},"web\n",[133,1421,1423],{"class":135,"line":1422},24,[133,1424,1245],{"emptyLinePlaceholder":54},[133,1426,1428,1431],{"class":135,"line":1427},25,[133,1429,1430],{"class":1233},"volumes",[133,1432,1253],{"class":169},[133,1434,1436,1439],{"class":135,"line":1435},26,[133,1437,1438],{"class":1233},"  static_volume",[133,1440,1253],{"class":169},[118,1442,1444],{"id":1443},"_4-configure-nginx","4. Configure Nginx",[10,1446,1084],{},[123,1448,1450],{"className":224,"code":1449,"language":226,"meta":128,"style":128},"nginx\u002Fdefault.conf\n",[130,1451,1452],{"__ignoreMap":128},[133,1453,1454],{"class":135,"line":136},[133,1455,1449],{"class":233},[10,1457,1458],{},"Add:",[123,1460,1464],{"className":1461,"code":1462,"language":1463,"meta":128,"style":128},"language-nginx shiki shiki-themes github-light github-dark","server {\n    listen 80;\n\n    location \u002Fstatic\u002F {\n        alias \u002Fapp\u002Fstatic\u002F;\n    }\n\n    location \u002F {\n        proxy_pass http:\u002F\u002Fweb:8000;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n    }\n}\n","nginx",[130,1465,1466,1474,1485,1489,1500,1508,1513,1517,1526,1534,1542,1549,1553],{"__ignoreMap":128},[133,1467,1468,1471],{"class":135,"line":136},[133,1469,1470],{"class":143},"server",[133,1472,1473],{"class":169}," {\n",[133,1475,1476,1479,1482],{"class":135,"line":456},[133,1477,1478],{"class":143},"    listen ",[133,1480,1481],{"class":139},"80",[133,1483,1484],{"class":169},";\n",[133,1486,1487],{"class":135,"line":466},[133,1488,1245],{"emptyLinePlaceholder":54},[133,1490,1491,1494,1497],{"class":135,"line":476},[133,1492,1493],{"class":143},"    location",[133,1495,1496],{"class":233}," \u002Fstatic\u002F ",[133,1498,1499],{"class":169},"{\n",[133,1501,1502,1505],{"class":135,"line":702},[133,1503,1504],{"class":143},"        alias ",[133,1506,1507],{"class":169},"\u002Fapp\u002Fstatic\u002F;\n",[133,1509,1510],{"class":135,"line":1126},[133,1511,1512],{"class":169},"    }\n",[133,1514,1515],{"class":135,"line":1138},[133,1516,1245],{"emptyLinePlaceholder":54},[133,1518,1519,1521,1524],{"class":135,"line":1293},[133,1520,1493],{"class":143},[133,1522,1523],{"class":233}," \u002F ",[133,1525,1499],{"class":169},[133,1527,1528,1531],{"class":135,"line":1301},[133,1529,1530],{"class":143},"        proxy_pass ",[133,1532,1533],{"class":169},"http:\u002F\u002Fweb:8000;\n",[133,1535,1536,1539],{"class":135,"line":1310},[133,1537,1538],{"class":143},"        proxy_set_header ",[133,1540,1541],{"class":169},"Host $host;\n",[133,1543,1544,1546],{"class":135,"line":1318},[133,1545,1538],{"class":143},[133,1547,1548],{"class":169},"X-Real-IP $remote_addr;\n",[133,1550,1551],{"class":135,"line":1326},[133,1552,1512],{"class":169},[133,1554,1555],{"class":135,"line":1334},[133,1556,1557],{"class":169},"}\n",[118,1559,1561],{"id":1560},"_5-configure-django","5. Configure Django",[10,1563,434,1564,438],{},[130,1565,437],{},[123,1567,1569],{"className":125,"code":1568,"language":127,"meta":128,"style":128},"DEBUG = False\n\nALLOWED_HOSTS = ['your-domain-or-ip']\n\nSTATIC_URL = '\u002Fstatic\u002F'\nSTATIC_ROOT = '\u002Fapp\u002Fstatic\u002F'\n",[130,1570,1571,1579,1583,1596,1600,1610],{"__ignoreMap":128},[133,1572,1573,1575,1577],{"class":135,"line":136},[133,1574,140],{"class":139},[133,1576,144],{"class":143},[133,1578,147],{"class":139},[133,1580,1581],{"class":135,"line":456},[133,1582,1245],{"emptyLinePlaceholder":54},[133,1584,1585,1587,1589,1591,1594],{"class":135,"line":466},[133,1586,164],{"class":139},[133,1588,144],{"class":143},[133,1590,170],{"class":169},[133,1592,1593],{"class":173},"'your-domain-or-ip'",[133,1595,183],{"class":169},[133,1597,1598],{"class":135,"line":476},[133,1599,1245],{"emptyLinePlaceholder":54},[133,1601,1602,1605,1607],{"class":135,"line":702},[133,1603,1604],{"class":139},"STATIC_URL",[133,1606,144],{"class":143},[133,1608,1609],{"class":173}," '\u002Fstatic\u002F'\n",[133,1611,1612,1614,1616],{"class":135,"line":1126},[133,1613,212],{"class":139},[133,1615,144],{"class":143},[133,1617,1618],{"class":173}," '\u002Fapp\u002Fstatic\u002F'\n",[118,1620,1622],{"id":1621},"_6-collect-static-files","6. Collect Static Files",[123,1624,1626],{"className":224,"code":1625,"language":226,"meta":128,"style":128},"docker-compose run web python manage.py collectstatic\n",[130,1627,1628],{"__ignoreMap":128},[133,1629,1630,1633,1636,1639,1642,1644],{"class":135,"line":136},[133,1631,1632],{"class":233},"docker-compose",[133,1634,1635],{"class":173}," run",[133,1637,1638],{"class":173}," web",[133,1640,1641],{"class":173}," python",[133,1643,236],{"class":173},[133,1645,239],{"class":173},[118,1647,1649],{"id":1648},"_7-start-application","7. Start Application",[123,1651,1653],{"className":224,"code":1652,"language":226,"meta":128,"style":128},"docker-compose up --build -d\n",[130,1654,1655],{"__ignoreMap":128},[133,1656,1657,1659,1662,1665],{"class":135,"line":136},[133,1658,1632],{"class":233},[133,1660,1661],{"class":173}," up",[133,1663,1664],{"class":139}," --build",[133,1666,1667],{"class":139}," -d\n",[118,1669,1671],{"id":1670},"_8-test-deployment","8. Test Deployment",[10,1673,1674],{},"Open:",[123,1676,1678],{"className":615,"code":1677,"language":617,"meta":128,"style":128},"http:\u002F\u002Fyour-domain-or-ip\n",[130,1679,1680],{"__ignoreMap":128},[133,1681,1682],{"class":135,"line":136},[133,1683,1677],{},[10,1685,1686],{},"👉 Your Django app should now be running",[36,1688],{},[39,1690,1692],{"id":1691},"common-issues","🔥 Common Issues",[36,1694],{},[118,1696,1698],{"id":1697},"static-files-not-loading","🔴 Static files not loading",[10,1700,1701],{},"Fix:",[123,1703,1704],{"className":224,"code":1625,"language":226,"meta":128,"style":128},[130,1705,1706],{"__ignoreMap":128},[133,1707,1708,1710,1712,1714,1716,1718],{"class":135,"line":136},[133,1709,1632],{"class":233},[133,1711,1635],{"class":173},[133,1713,1638],{"class":173},[133,1715,1641],{"class":173},[133,1717,236],{"class":173},[133,1719,239],{"class":173},[10,1721,365],{},[10,1723,1724,1725],{},"Volume mapping\nNginx ",[130,1726,1727],{},"alias",[118,1729,1731],{"id":1730},"_502-bad-gateway","🔴 502 Bad Gateway",[10,1733,365],{},[123,1735,1737],{"className":224,"code":1736,"language":226,"meta":128,"style":128},"docker-compose logs web\ndocker-compose logs nginx\n",[130,1738,1739,1749],{"__ignoreMap":128},[133,1740,1741,1743,1746],{"class":135,"line":136},[133,1742,1632],{"class":233},[133,1744,1745],{"class":173}," logs",[133,1747,1748],{"class":173}," web\n",[133,1750,1751,1753,1755],{"class":135,"line":456},[133,1752,1632],{"class":233},[133,1754,1745],{"class":173},[133,1756,565],{"class":173},[118,1758,1760],{"id":1759},"container-not-starting","🔴 Container not starting",[123,1762,1764],{"className":224,"code":1763,"language":226,"meta":128,"style":128},"docker-compose ps\n",[130,1765,1766],{"__ignoreMap":128},[133,1767,1768,1770],{"class":135,"line":136},[133,1769,1632],{"class":233},[133,1771,1772],{"class":173}," ps\n",[118,1774,1776],{"id":1775},"changes-not-updating","🔴 Changes not updating",[123,1778,1779],{"className":224,"code":1652,"language":226,"meta":128,"style":128},[130,1780,1781],{"__ignoreMap":128},[133,1782,1783,1785,1787,1789],{"class":135,"line":136},[133,1784,1632],{"class":233},[133,1786,1661],{"class":173},[133,1788,1664],{"class":139},[133,1790,1667],{"class":139},[39,1792,1794],{"id":1793},"debugging-tips","🧠 Debugging Tips",[118,1796,1798],{"id":1797},"view-logs","View logs",[123,1800,1802],{"className":224,"code":1801,"language":226,"meta":128,"style":128},"docker-compose logs -f\n",[130,1803,1804],{"__ignoreMap":128},[133,1805,1806,1808,1810],{"class":135,"line":136},[133,1807,1632],{"class":233},[133,1809,1745],{"class":173},[133,1811,1812],{"class":139}," -f\n",[118,1814,1816],{"id":1815},"restart-everything","Restart everything",[123,1818,1820],{"className":224,"code":1819,"language":226,"meta":128,"style":128},"docker-compose down\ndocker-compose up --build -d\n",[130,1821,1822,1829],{"__ignoreMap":128},[133,1823,1824,1826],{"class":135,"line":136},[133,1825,1632],{"class":233},[133,1827,1828],{"class":173}," down\n",[133,1830,1831,1833,1835,1837],{"class":135,"line":456},[133,1832,1632],{"class":233},[133,1834,1661],{"class":173},[133,1836,1664],{"class":139},[133,1838,1667],{"class":139},[39,1840,1841],{"id":975},"✅ Production Checklist",[17,1843,1845,1851,1857,1862,1868,1874],{"className":1844},[46],[20,1846,1848,1850],{"className":1847},[50],[52,1849],{"disabled":54,"type":55}," DEBUG = False",[20,1852,1854,1856],{"className":1853},[50],[52,1855],{"disabled":54,"type":55}," ALLOWED_HOSTS set",[20,1858,1860,68],{"className":1859},[50],[52,1861],{"disabled":54,"type":55},[20,1863,1865,1867],{"className":1864},[50],[52,1866],{"disabled":54,"type":55}," Containers running",[20,1869,1871,1873],{"className":1870},[50],[52,1872],{"disabled":54,"type":55}," Nginx proxy working",[20,1875,1877,1879],{"className":1876},[50],[52,1878],{"disabled":54,"type":55}," 🔐 (Optional) Add HTTPS",[10,1881,1882],{},"Use Nginx + Certbot or a reverse proxy container.",[36,1884],{},[758,1886,1888],{"title":1887,"type":761},"After Docker is working, verify the full production stack",[10,1889,1890,1891,1894,1895,1899],{},"Pair this setup with the base ",[244,1892,1893],{"href":307},"Nginx + Gunicorn deployment guide",", then use the ",[244,1896,1898],{"href":1897},"\u002Fproduction-checklist\u002Fdjango-production-checklist-everything-you-must-do","production checklist"," before launch.",[36,1901],{},[39,1903,822],{"id":821},[17,1905,1906,1910,1915],{},[20,1907,1908],{},[244,1909,308],{"href":307},[20,1911,1912],{},[244,1913,1914],{"href":815},"Zero Downtime Django Deployment",[20,1916,1917],{},[244,1918,1919],{"href":1897},"Django Production Checklist",[36,1921],{},[39,1923,850],{"id":849},[118,1925,1927],{"id":1926},"what-is-docker","What is Docker?",[10,1929,1930],{},"Docker is a platform for developing, shipping, and running applications in containers.",[118,1932,1934],{"id":1933},"why-use-docker-for-django","Why use Docker for Django?",[17,1936,1937,1940,1942],{},[20,1938,1939],{},"Reproducible environments",[20,1941,878],{},[20,1943,1944],{},"Isolation",[118,1946,1948],{"id":1947},"do-i-need-docker-in-production","Do I need Docker in production?",[10,1950,1951],{},"Not required—but highly recommended for consistency.",[118,1953,1955],{"id":1954},"how-do-i-deploy-django-with-docker","How do I deploy Django with Docker?",[10,1957,1958],{},"Check out the guide above.",[118,1960,1962],{"id":1961},"can-i-add-a-database","Can I add a database?",[10,1964,1965],{},"Yes—add PostgreSQL as another service in docker-compose.yml.",[36,1967],{},[39,1969,905],{"id":904},[10,1971,1972],{},"Docker makes Django deployments:",[17,1974,1975,1978,1981],{},[20,1976,1977],{},"Repeatable",[20,1979,1980],{},"Portable",[20,1982,1983],{},"Easier to manage",[36,1985],{},[10,1987,924],{},[10,1989,1990],{},"A pre-configured Docker setup can save hours of setup and debugging.",[929,1992,1993],{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .s9eBZ, html code.shiki .s9eBZ{--shiki-default:#22863A;--shiki-dark:#85E89D}",{"title":128,"searchDepth":466,"depth":466,"links":1995},[1996,1997,1998,2009,2015,2019,2020,2021,2028],{"id":1013,"depth":456,"text":1014},{"id":1040,"depth":456,"text":1041},{"id":1065,"depth":456,"text":1066,"children":1999},[2000,2001,2002,2004,2005,2006,2007,2008],{"id":1080,"depth":466,"text":1081},{"id":1147,"depth":466,"text":1148},{"id":1217,"depth":466,"text":2003},"3. Create docker-compose.yml",{"id":1443,"depth":466,"text":1444},{"id":1560,"depth":466,"text":1561},{"id":1621,"depth":466,"text":1622},{"id":1648,"depth":466,"text":1649},{"id":1670,"depth":466,"text":1671},{"id":1691,"depth":456,"text":1692,"children":2010},[2011,2012,2013,2014],{"id":1697,"depth":466,"text":1698},{"id":1730,"depth":466,"text":1731},{"id":1759,"depth":466,"text":1760},{"id":1775,"depth":466,"text":1776},{"id":1793,"depth":456,"text":1794,"children":2016},[2017,2018],{"id":1797,"depth":466,"text":1798},{"id":1815,"depth":466,"text":1816},{"id":975,"depth":456,"text":1841},{"id":821,"depth":456,"text":822},{"id":849,"depth":456,"text":850,"children":2022},[2023,2024,2025,2026,2027],{"id":1926,"depth":466,"text":1927},{"id":1933,"depth":466,"text":1934},{"id":1947,"depth":466,"text":1948},{"id":1954,"depth":466,"text":1955},{"id":1961,"depth":466,"text":1962},{"id":904,"depth":456,"text":905},"Containers","A comprehensive guide to deploying a Django application using Docker in a production environment. Learn how to create Dockerfiles, manage environment variables, and set up a reverse proxy for optimal performance.",{},"\u002Fdjango-docker-production-setup-complete-guide","3",[307,815,1897],"advanced","deploy",{"title":986,"description":2030},"django-docker-production-setup-complete-guide",[979,2040,980],"docker","QybtepMr-lAAw-_qqoKjCAm39fgg8mAPp2q0ZVO9xvw",{"id":2043,"title":2044,"body":2045,"category":3044,"description":991,"extension":969,"meta":3045,"navigation":54,"path":3046,"priority":972,"related":3047,"role":3048,"section":2036,"seo":3049,"stem":3050,"tags":3051,"__hash__":3053},"articles\u002Fdeploy-django-with-nginx-gunicorn-step-by-step.md","Deploy Django with Nginx + Gunicorn (Step-by-Step)",{"type":7,"value":2046,"toc":3023},[2047,2050,2061,2064,2066,2070,2085,2089,2095,2097,2106,2114,2116,2118,2129,2131,2135,2178,2180,2183,2210,2212,2215,2217,2223,2242,2244,2247,2264,2266,2275,2278,2287,2289,2293,2312,2314,2317,2331,2334,2336,2340,2343,2443,2445,2448,2474,2476,2479,2495,2497,2501,2526,2528,2531,2546,2549,2551,2554,2640,2642,2645,2684,2686,2690,2693,2707,2709,2712,2724,2726,2730,2758,2760,2764,2767,2775,2778,2787,2790,2792,2794,2796,2798,2800,2825,2827,2829,2841,2843,2846,2855,2857,2860,2895,2901,2927,2929,2942,2944,2946,2965,2967,2969,2974,2977,2982,2996,2999,3001,3003,3006,3017,3020],[10,2048,2049],{},"In this tutorial, you’ll learn how to deploy a Django application in production using:",[17,2051,2052,2055,2058],{},[20,2053,2054],{},"Nginx (web server)",[20,2056,2057],{},"Gunicorn (application server)",[20,2059,2060],{},"Ubuntu (VPS)",[10,2062,2063],{},"By the end, your Django app will be live and accessible via your server.",[36,2065],{},[39,2067,2069],{"id":2068},"quick-overview-what-youll-do","⚡ Quick Overview (What You’ll Do)",[1022,2071,2072,2075,2077,2080,2082],{},[20,2073,2074],{},"Set up your Django project",[20,2076,277],{},[20,2078,2079],{},"Configure systemd (service)",[20,2081,221],{},[20,2083,2084],{},"Serve static files",[39,2086,2088],{"id":2087},"architecture-how-it-works","🧠 Architecture (How it works)",[10,2090,2091],{},[1045,2092],{"alt":2093,"src":2094},"Nginx to Gunicorn to Django request flow","\u002Fimages\u002Fnginx-gunicorn-django-flow.png",[10,2096,1051],{},[123,2098,2100],{"className":615,"code":2099,"language":617,"meta":128,"style":128},"Client → Nginx → Gunicorn → Django\n",[130,2101,2102],{"__ignoreMap":128},[133,2103,2104],{"class":135,"line":136},[133,2105,2099],{},[17,2107,2108,2111],{},[20,2109,2110],{},"Nginx handles HTTP + static files",[20,2112,2113],{},"Gunicorn runs your Django app",[36,2115],{},[39,2117,1066],{"id":1065},[17,2119,2120,2123,2126],{},[20,2121,2122],{},"Ubuntu server (22.04+)",[20,2124,2125],{},"Python 3 installed",[20,2127,2128],{},"A working Django project",[36,2130],{},[118,2132,2134],{"id":2133},"_1-set-up-project","1. Set Up Project",[123,2136,2138],{"className":224,"code":2137,"language":226,"meta":128,"style":128},"sudo mkdir -p \u002Fvar\u002Fwww\u002Fmyproject\nsudo chown -R $USER:$USER \u002Fvar\u002Fwww\u002Fmyproject\ncd \u002Fvar\u002Fwww\u002Fmyproject\n",[130,2139,2140,2152,2171],{"__ignoreMap":128},[133,2141,2142,2144,2147,2150],{"class":135,"line":136},[133,2143,293],{"class":233},[133,2145,2146],{"class":173}," mkdir",[133,2148,2149],{"class":139}," -p",[133,2151,513],{"class":173},[133,2153,2154,2156,2158,2160,2163,2165,2168],{"class":135,"line":456},[133,2155,293],{"class":233},[133,2157,504],{"class":173},[133,2159,507],{"class":139},[133,2161,2162],{"class":169}," $USER",[133,2164,438],{"class":173},[133,2166,2167],{"class":169},"$USER ",[133,2169,2170],{"class":173},"\u002Fvar\u002Fwww\u002Fmyproject\n",[133,2172,2173,2176],{"class":135,"line":466},[133,2174,2175],{"class":139},"cd",[133,2177,513],{"class":173},[36,2179],{},[10,2181,2182],{},"Create virtual environment and activate it:",[123,2184,2186],{"className":224,"code":2185,"language":226,"meta":128,"style":128},"python3 -m venv venv\nsource venv\u002Fbin\u002Factivate\n",[130,2187,2188,2202],{"__ignoreMap":128},[133,2189,2190,2193,2196,2199],{"class":135,"line":136},[133,2191,2192],{"class":233},"python3",[133,2194,2195],{"class":139}," -m",[133,2197,2198],{"class":173}," venv",[133,2200,2201],{"class":173}," venv\n",[133,2203,2204,2207],{"class":135,"line":456},[133,2205,2206],{"class":139},"source",[133,2208,2209],{"class":173}," venv\u002Fbin\u002Factivate\n",[36,2211],{},[10,2213,2214],{},"Install dependencies",[36,2216],{},[10,2218,2219,2220],{},"Create or upload your project files to ",[130,2221,2222],{},"\u002Fvar\u002Fwww\u002Fmyproject",[123,2224,2226],{"className":224,"code":2225,"language":226,"meta":128,"style":128},"django-admin startproject myproject .\n",[130,2227,2228],{"__ignoreMap":128},[133,2229,2230,2233,2236,2239],{"class":135,"line":136},[133,2231,2232],{"class":233},"django-admin",[133,2234,2235],{"class":173}," startproject",[133,2237,2238],{"class":173}," myproject",[133,2240,2241],{"class":173}," .\n",[36,2243],{},[10,2245,2246],{},"Test Django:",[123,2248,2250],{"className":224,"code":2249,"language":226,"meta":128,"style":128},"python manage.py runserver 0.0.0.0:8000\n",[130,2251,2252],{"__ignoreMap":128},[133,2253,2254,2256,2258,2261],{"class":135,"line":136},[133,2255,127],{"class":233},[133,2257,236],{"class":173},[133,2259,2260],{"class":173}," runserver",[133,2262,2263],{"class":173}," 0.0.0.0:8000\n",[10,2265,1674],{},[123,2267,2269],{"className":224,"code":2268,"language":226,"meta":128,"style":128},"http:\u002F\u002Fyou-server-ip:8000\u002F\n",[130,2270,2271],{"__ignoreMap":128},[133,2272,2273],{"class":135,"line":136},[133,2274,2268],{"class":233},[10,2276,2277],{},"or",[123,2279,2281],{"className":224,"code":2280,"language":226,"meta":128,"style":128},"http:\u002F\u002Flocalhost:8000\u002F\n",[130,2282,2283],{"__ignoreMap":128},[133,2284,2285],{"class":135,"line":136},[133,2286,2280],{"class":233},[36,2288],{},[118,2290,2292],{"id":2291},"_2-configure-gunicorn","2. Configure Gunicorn",[123,2294,2296],{"className":224,"code":2295,"language":226,"meta":128,"style":128},"gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application\n",[130,2297,2298],{"__ignoreMap":128},[133,2299,2300,2303,2306,2309],{"class":135,"line":136},[133,2301,2302],{"class":233},"gunicorn",[133,2304,2305],{"class":139}," --bind",[133,2307,2308],{"class":173}," 0.0.0.0:8000",[133,2310,2311],{"class":173}," myproject.wsgi:application\n",[36,2313],{},[10,2315,2316],{},"Test Gunicorn manually:",[123,2318,2319],{"className":224,"code":2295,"language":226,"meta":128,"style":128},[130,2320,2321],{"__ignoreMap":128},[133,2322,2323,2325,2327,2329],{"class":135,"line":136},[133,2324,2302],{"class":233},[133,2326,2305],{"class":139},[133,2328,2308],{"class":173},[133,2330,2311],{"class":173},[10,2332,2333],{},"If this works → proceed.",[36,2335],{},[118,2337,2339],{"id":2338},"_3-create-gunicorn-systemd-service","3. Create Gunicorn systemd Service",[10,2341,2342],{},"Create file:",[123,2344,2348],{"className":2345,"code":2346,"language":2347,"meta":128,"style":128},"language-ini shiki shiki-themes github-light github-dark","[Unit]\nDescription=gunicorn daemon\nAfter=network.target\n\n[Service]\nUser=www-data\nGroup=www-data\nWorkingDirectory=\u002Fvar\u002Fwww\u002Fmyproject\nExecStart=\u002Fvar\u002Fwww\u002Fmyproject\u002Fvenv\u002Fbin\u002Fgunicorn \\\n    --workers 3 \\\n    --bind unix:\u002Fvar\u002Fwww\u002Fmyproject\u002Fgunicorn.sock \\\n    myproject.wsgi:application\n\n[Install]\nWantedBy=multi-user.target\n","ini",[130,2349,2350,2355,2363,2371,2375,2380,2388,2395,2403,2411,2416,2421,2426,2430,2435],{"__ignoreMap":128},[133,2351,2352],{"class":135,"line":136},[133,2353,2354],{"class":233},"[Unit]\n",[133,2356,2357,2360],{"class":135,"line":456},[133,2358,2359],{"class":143},"Description",[133,2361,2362],{"class":169},"=gunicorn daemon\n",[133,2364,2365,2368],{"class":135,"line":466},[133,2366,2367],{"class":143},"After",[133,2369,2370],{"class":169},"=network.target\n",[133,2372,2373],{"class":135,"line":476},[133,2374,1245],{"emptyLinePlaceholder":54},[133,2376,2377],{"class":135,"line":702},[133,2378,2379],{"class":233},"[Service]\n",[133,2381,2382,2385],{"class":135,"line":1126},[133,2383,2384],{"class":143},"User",[133,2386,2387],{"class":169},"=www-data\n",[133,2389,2390,2393],{"class":135,"line":1138},[133,2391,2392],{"class":143},"Group",[133,2394,2387],{"class":169},[133,2396,2397,2400],{"class":135,"line":1293},[133,2398,2399],{"class":143},"WorkingDirectory",[133,2401,2402],{"class":169},"=\u002Fvar\u002Fwww\u002Fmyproject\n",[133,2404,2405,2408],{"class":135,"line":1301},[133,2406,2407],{"class":143},"ExecStart",[133,2409,2410],{"class":169},"=\u002Fvar\u002Fwww\u002Fmyproject\u002Fvenv\u002Fbin\u002Fgunicorn \\\n",[133,2412,2413],{"class":135,"line":1310},[133,2414,2415],{"class":169},"    --workers 3 \\\n",[133,2417,2418],{"class":135,"line":1318},[133,2419,2420],{"class":169},"    --bind unix:\u002Fvar\u002Fwww\u002Fmyproject\u002Fgunicorn.sock \\\n",[133,2422,2423],{"class":135,"line":1326},[133,2424,2425],{"class":169},"    myproject.wsgi:application\n",[133,2427,2428],{"class":135,"line":1334},[133,2429,1245],{"emptyLinePlaceholder":54},[133,2431,2432],{"class":135,"line":1339},[133,2433,2434],{"class":233},"[Install]\n",[133,2436,2437,2440],{"class":135,"line":1347},[133,2438,2439],{"class":143},"WantedBy",[133,2441,2442],{"class":169},"=multi-user.target\n",[36,2444],{},[10,2446,2447],{},"Start Gunicorn:",[123,2449,2451],{"className":224,"code":2450,"language":226,"meta":128,"style":128},"sudo systemctl start gunicorn\nsudo systemctl enable gunicorn\n",[130,2452,2453,2464],{"__ignoreMap":128},[133,2454,2455,2457,2459,2462],{"class":135,"line":136},[133,2456,293],{"class":233},[133,2458,296],{"class":173},[133,2460,2461],{"class":173}," start",[133,2463,302],{"class":173},[133,2465,2466,2468,2470,2472],{"class":135,"line":456},[133,2467,293],{"class":233},[133,2469,296],{"class":173},[133,2471,299],{"class":173},[133,2473,302],{"class":173},[36,2475],{},[10,2477,2478],{},"Verify Gunicorn is running:",[123,2480,2482],{"className":224,"code":2481,"language":226,"meta":128,"style":128},"sudo systemctl status gunicorn\n",[130,2483,2484],{"__ignoreMap":128},[133,2485,2486,2488,2490,2493],{"class":135,"line":136},[133,2487,293],{"class":233},[133,2489,296],{"class":173},[133,2491,2492],{"class":173}," status",[133,2494,302],{"class":173},[36,2496],{},[118,2498,2500],{"id":2499},"_4-install-and-configure-nginx","4. Install and Configure Nginx",[123,2502,2504],{"className":224,"code":2503,"language":226,"meta":128,"style":128},"sudo apt update\nsudo apt install nginx\n",[130,2505,2506,2516],{"__ignoreMap":128},[133,2507,2508,2510,2513],{"class":135,"line":136},[133,2509,293],{"class":233},[133,2511,2512],{"class":173}," apt",[133,2514,2515],{"class":173}," update\n",[133,2517,2518,2520,2522,2524],{"class":135,"line":456},[133,2519,293],{"class":233},[133,2521,2512],{"class":173},[133,2523,677],{"class":173},[133,2525,565],{"class":173},[36,2527],{},[10,2529,2530],{},"Create config file:",[123,2532,2534],{"className":224,"code":2533,"language":226,"meta":128,"style":128},"sudo nano \u002Fetc\u002Fnginx\u002Fsites-available\u002Fmyproject\n",[130,2535,2536],{"__ignoreMap":128},[133,2537,2538,2540,2543],{"class":135,"line":136},[133,2539,293],{"class":233},[133,2541,2542],{"class":173}," nano",[133,2544,2545],{"class":173}," \u002Fetc\u002Fnginx\u002Fsites-available\u002Fmyproject\n",[10,2547,2548],{},"Or use your favourite editor.",[36,2550],{},[10,2552,2553],{},"Add this config:",[123,2555,2557],{"className":1461,"code":2556,"language":1463,"meta":128,"style":128},"server {\n    listen 80;\n    server_name your_domain_or_ip;\n\n    location \u002Fstatic\u002F {\n        root \u002Fvar\u002Fwww\u002Fmyproject;\n    }\n\n    location \u002F {\n        include proxy_params;\n        proxy_pass http:\u002F\u002Funix:\u002Fvar\u002Fwww\u002Fmyproject\u002Fgunicorn.sock;\n    }\n}\n",[130,2558,2559,2565,2573,2581,2585,2593,2601,2605,2609,2617,2625,2632,2636],{"__ignoreMap":128},[133,2560,2561,2563],{"class":135,"line":136},[133,2562,1470],{"class":143},[133,2564,1473],{"class":169},[133,2566,2567,2569,2571],{"class":135,"line":456},[133,2568,1478],{"class":143},[133,2570,1481],{"class":139},[133,2572,1484],{"class":169},[133,2574,2575,2578],{"class":135,"line":466},[133,2576,2577],{"class":143},"    server_name ",[133,2579,2580],{"class":169},"your_domain_or_ip;\n",[133,2582,2583],{"class":135,"line":476},[133,2584,1245],{"emptyLinePlaceholder":54},[133,2586,2587,2589,2591],{"class":135,"line":702},[133,2588,1493],{"class":143},[133,2590,1496],{"class":233},[133,2592,1499],{"class":169},[133,2594,2595,2598],{"class":135,"line":1126},[133,2596,2597],{"class":143},"        root ",[133,2599,2600],{"class":169},"\u002Fvar\u002Fwww\u002Fmyproject;\n",[133,2602,2603],{"class":135,"line":1138},[133,2604,1512],{"class":169},[133,2606,2607],{"class":135,"line":1293},[133,2608,1245],{"emptyLinePlaceholder":54},[133,2610,2611,2613,2615],{"class":135,"line":1301},[133,2612,1493],{"class":143},[133,2614,1523],{"class":233},[133,2616,1499],{"class":169},[133,2618,2619,2622],{"class":135,"line":1310},[133,2620,2621],{"class":143},"        include ",[133,2623,2624],{"class":169},"proxy_params;\n",[133,2626,2627,2629],{"class":135,"line":1318},[133,2628,1530],{"class":143},[133,2630,2631],{"class":169},"http:\u002F\u002Funix:\u002Fvar\u002Fwww\u002Fmyproject\u002Fgunicorn.sock;\n",[133,2633,2634],{"class":135,"line":1326},[133,2635,1512],{"class":169},[133,2637,2638],{"class":135,"line":1334},[133,2639,1557],{"class":169},[36,2641],{},[10,2643,2644],{},"Enable site:",[123,2646,2648],{"className":224,"code":2647,"language":226,"meta":128,"style":128},"sudo ln -s \u002Fetc\u002Fnginx\u002Fsites-available\u002Fmyproject \u002Fetc\u002Fnginx\u002Fsites-enabled\nsudo nginx -t\nsudo systemctl restart nginx\n",[130,2649,2650,2666,2674],{"__ignoreMap":128},[133,2651,2652,2654,2657,2660,2663],{"class":135,"line":136},[133,2653,293],{"class":233},[133,2655,2656],{"class":173}," ln",[133,2658,2659],{"class":139}," -s",[133,2661,2662],{"class":173}," \u002Fetc\u002Fnginx\u002Fsites-available\u002Fmyproject",[133,2664,2665],{"class":173}," \u002Fetc\u002Fnginx\u002Fsites-enabled\n",[133,2667,2668,2670,2672],{"class":135,"line":456},[133,2669,293],{"class":233},[133,2671,337],{"class":173},[133,2673,340],{"class":139},[133,2675,2676,2678,2680,2682],{"class":135,"line":466},[133,2677,293],{"class":233},[133,2679,296],{"class":173},[133,2681,709],{"class":173},[133,2683,565],{"class":173},[36,2685],{},[118,2687,2689],{"id":2688},"_5-configure-static-files","5. Configure Static Files",[10,2691,2692],{},"In settings.py:",[123,2694,2696],{"className":125,"code":2695,"language":127,"meta":128,"style":128},"STATIC_ROOT = '\u002Fvar\u002Fwww\u002Fmyproject\u002Fstatic\u002F'\n",[130,2697,2698],{"__ignoreMap":128},[133,2699,2700,2702,2704],{"class":135,"line":136},[133,2701,212],{"class":139},[133,2703,144],{"class":143},[133,2705,2706],{"class":173}," '\u002Fvar\u002Fwww\u002Fmyproject\u002Fstatic\u002F'\n",[36,2708],{},[10,2710,2711],{},"Collect static files:",[123,2713,2714],{"className":224,"code":225,"language":226,"meta":128,"style":128},[130,2715,2716],{"__ignoreMap":128},[133,2717,2718,2720,2722],{"class":135,"line":136},[133,2719,127],{"class":233},[133,2721,236],{"class":173},[133,2723,239],{"class":173},[36,2725],{},[118,2727,2729],{"id":2728},"_6-fix-permissions","6. Fix Permissions",[123,2731,2732],{"className":224,"code":495,"language":226,"meta":128,"style":128},[130,2733,2734,2746],{"__ignoreMap":128},[133,2735,2736,2738,2740,2742,2744],{"class":135,"line":136},[133,2737,293],{"class":233},[133,2739,504],{"class":173},[133,2741,507],{"class":139},[133,2743,510],{"class":173},[133,2745,513],{"class":173},[133,2747,2748,2750,2752,2754,2756],{"class":135,"line":456},[133,2749,293],{"class":233},[133,2751,520],{"class":173},[133,2753,507],{"class":139},[133,2755,525],{"class":139},[133,2757,513],{"class":173},[36,2759],{},[118,2761,2763],{"id":2762},"_7-final-test","7. Final Test",[10,2765,2766],{},"Visit:",[123,2768,2769],{"className":615,"code":1677,"language":617,"meta":128,"style":128},[130,2770,2771],{"__ignoreMap":128},[133,2772,2773],{"class":135,"line":136},[133,2774,1677],{},[10,2776,2777],{},"or:",[123,2779,2781],{"className":615,"code":2780,"language":617,"meta":128,"style":128},"http:\u002F\u002Flocalhost\n",[130,2782,2783],{"__ignoreMap":128},[133,2784,2785],{"class":135,"line":136},[133,2786,2780],{},[10,2788,2789],{},"👉 Your Django app should now be live and served by Nginx + Gunicorn!",[36,2791],{},[39,2793,1692],{"id":1691},[36,2795],{},[118,2797,1731],{"id":1730},[10,2799,1701],{},[123,2801,2803],{"className":224,"code":2802,"language":226,"meta":128,"style":128},"sudo systemctl restart gunicorn\nsudo systemctl restart nginx\n",[130,2804,2805,2815],{"__ignoreMap":128},[133,2806,2807,2809,2811,2813],{"class":135,"line":136},[133,2808,293],{"class":233},[133,2810,296],{"class":173},[133,2812,709],{"class":173},[133,2814,302],{"class":173},[133,2816,2817,2819,2821,2823],{"class":135,"line":456},[133,2818,293],{"class":233},[133,2820,296],{"class":173},[133,2822,709],{"class":173},[133,2824,565],{"class":173},[36,2826],{},[118,2828,1698],{"id":1697},[17,2830,2831,2837],{},[20,2832,2833,2834,2836],{},"Check ",[130,2835,212],{}," in settings.py",[20,2838,215,2839],{},[130,2840,218],{},[36,2842],{},[10,2844,2845],{},"🔴 Permission denied",[123,2847,2849],{"className":615,"code":2848,"language":617,"meta":128,"style":128},"sudo chown -R www-data:www-data \u002Fvar\u002Fwww\u002Fmyproject\n",[130,2850,2851],{"__ignoreMap":128},[133,2852,2853],{"class":135,"line":136},[133,2854,2848],{},[36,2856],{},[39,2858,2859],{"id":975},"🧠 Production Checklist",[17,2861,2863,2869,2874,2879,2884,2889],{"className":2862},[46],[20,2864,2866,2868],{"className":2865},[50],[52,2867],{"disabled":54,"type":55}," Gunicorn running",[20,2870,2872,86],{"className":2871},[50],[52,2873],{"disabled":54,"type":55},[20,2875,2877,68],{"className":2876},[50],[52,2878],{"disabled":54,"type":55},[20,2880,2882,1850],{"className":2881},[50],[52,2883],{"disabled":54,"type":55},[20,2885,2887,1856],{"className":2886},[50],[52,2888],{"disabled":54,"type":55},[20,2890,2892,2894],{"className":2891},[50],[52,2893],{"disabled":54,"type":55}," 🔐 (Optional) Enable HTTPS",[10,2896,394,2897,2900],{},[244,2898,400],{"href":397,"rel":2899},[399]," with Certbot:",[123,2902,2904],{"className":224,"code":2903,"language":226,"meta":128,"style":128},"sudo apt install certbot python3-certbot-nginx\nsudo certbot --nginx\n",[130,2905,2906,2919],{"__ignoreMap":128},[133,2907,2908,2910,2912,2914,2916],{"class":135,"line":136},[133,2909,293],{"class":233},[133,2911,2512],{"class":173},[133,2913,677],{"class":173},[133,2915,413],{"class":173},[133,2917,2918],{"class":173}," python3-certbot-nginx\n",[133,2920,2921,2923,2925],{"class":135,"line":456},[133,2922,293],{"class":233},[133,2924,413],{"class":173},[133,2926,416],{"class":139},[36,2928],{},[758,2930,2932],{"title":2931,"type":761},"Next: secure and validate this deployment",[10,2933,2934,2935,2938,2939,2941],{},"Once the stack is live, enable ",[244,2936,2937],{"href":775},"HTTPS with Let's Encrypt"," and run the ",[244,2940,1898],{"href":1897}," before you call the rollout complete.",[36,2943],{},[39,2945,822],{"id":821},[17,2947,2948,2952,2956,2961],{},[20,2949,2950],{},[244,2951,788],{"href":787},[20,2953,2954],{},[244,2955,247],{"href":246},[20,2957,2958],{},[244,2959,2960],{"href":781},"Docker-based Django deployment",[20,2962,2963],{},[244,2964,776],{"href":775},[36,2966],{},[39,2968,850],{"id":849},[10,2970,2971],{},[353,2972,2973],{},"Why use Gunicorn?",[10,2975,2976],{},"It’s a production-grade WSGI server designed to run Django apps efficiently.",[10,2978,2979],{},[353,2980,2981],{},"Why use Nginx?",[17,2983,2984,2987,2990,2993],{},[20,2985,2986],{},"Handles HTTP requests",[20,2988,2989],{},"Serves static files",[20,2991,2992],{},"Acts as a reverse proxy",[20,2994,2995],{},"Can I deploy without Nginx?",[10,2997,2998],{},"Yes, but not recommended for production.",[36,3000],{},[39,3002,905],{"id":904},[10,3004,3005],{},"This setup is:",[17,3007,3008,3011,3014],{},[20,3009,3010],{},"Simple",[20,3012,3013],{},"Reliable",[20,3015,3016],{},"Widely used",[10,3018,3019],{},"If something breaks, you now have a clear structure to debug it.",[929,3021,3022],{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}",{"title":128,"searchDepth":466,"depth":466,"links":3024},[3025,3026,3027,3036,3040,3041,3042,3043],{"id":2068,"depth":456,"text":2069},{"id":2087,"depth":456,"text":2088},{"id":1065,"depth":456,"text":1066,"children":3028},[3029,3030,3031,3032,3033,3034,3035],{"id":2133,"depth":466,"text":2134},{"id":2291,"depth":466,"text":2292},{"id":2338,"depth":466,"text":2339},{"id":2499,"depth":466,"text":2500},{"id":2688,"depth":466,"text":2689},{"id":2728,"depth":466,"text":2729},{"id":2762,"depth":466,"text":2763},{"id":1691,"depth":456,"text":1692,"children":3037},[3038,3039],{"id":1730,"depth":466,"text":1731},{"id":1697,"depth":466,"text":1698},{"id":975,"depth":456,"text":2859},{"id":821,"depth":456,"text":822},{"id":849,"depth":456,"text":850},{"id":904,"depth":456,"text":905},"Deployment",{},"\u002Fdeploy-django-with-nginx-gunicorn-step-by-step",[787,246,775],"entry",{"title":2044,"description":991},"deploy-django-with-nginx-gunicorn-step-by-step",[979,1463,2302,3052],"tutorial","gGBJad9rM20wvBKJBWNFY_RvIZrGb-6r5jCld-Na060",{"id":4,"title":5,"body":3055,"category":967,"description":968,"extension":969,"meta":3752,"navigation":54,"path":971,"priority":972,"related":3753,"role":974,"section":975,"seo":3754,"stem":977,"tags":3755,"__hash__":982},{"type":7,"value":3056,"toc":3717},[3057,3059,3061,3071,3073,3075,3077,3130,3132,3134,3136,3148,3150,3152,3172,3174,3176,3182,3184,3186,3198,3210,3214,3216,3224,3228,3230,3232,3240,3254,3258,3260,3262,3270,3282,3284,3286,3288,3292,3296,3300,3306,3318,3320,3325,3337,3339,3345,3347,3351,3387,3389,3391,3393,3421,3423,3425,3427,3429,3453,3455,3457,3459,3481,3483,3485,3487,3495,3501,3503,3505,3509,3511,3513,3515,3517,3563,3565,3567,3569,3571,3573,3575,3577,3579,3581,3583,3585,3587,3589,3591,3633,3635,3637,3659,3661,3663,3665,3667,3669,3671,3673,3675,3681,3683,3685,3695,3697,3699,3701,3709,3711,3713,3715],[10,3058,12],{},[10,3060,15],{},[17,3062,3063,3065,3067,3069],{},[20,3064,22],{},[20,3066,25],{},[20,3068,28],{},[20,3070,31],{},[10,3072,34],{},[36,3074],{},[39,3076,42],{"id":41},[17,3078,3080,3085,3090,3095,3100,3105,3110,3115,3120,3125],{"className":3079},[46],[20,3081,3083,56],{"className":3082},[50],[52,3084],{"disabled":54,"type":55},[20,3086,3088,62],{"className":3087},[50],[52,3089],{"disabled":54,"type":55},[20,3091,3093,68],{"className":3092},[50],[52,3094],{"disabled":54,"type":55},[20,3096,3098,74],{"className":3097},[50],[52,3099],{"disabled":54,"type":55},[20,3101,3103,80],{"className":3102},[50],[52,3104],{"disabled":54,"type":55},[20,3106,3108,86],{"className":3107},[50],[52,3109],{"disabled":54,"type":55},[20,3111,3113,92],{"className":3112},[50],[52,3114],{"disabled":54,"type":55},[20,3116,3118,98],{"className":3117},[50],[52,3119],{"disabled":54,"type":55},[20,3121,3123,104],{"className":3122},[50],[52,3124],{"disabled":54,"type":55},[20,3126,3128,110],{"className":3127},[50],[52,3129],{"disabled":54,"type":55},[36,3131],{},[39,3133,116],{"id":115},[118,3135,121],{"id":120},[123,3137,3138],{"className":125,"code":126,"language":127,"meta":128,"style":128},[130,3139,3140],{"__ignoreMap":128},[133,3141,3142,3144,3146],{"class":135,"line":136},[133,3143,140],{"class":139},[133,3145,144],{"class":143},[133,3147,147],{"class":139},[10,3149,150],{},[118,3151,154],{"id":153},[123,3153,3154],{"className":125,"code":157,"language":127,"meta":128,"style":128},[130,3155,3156],{"__ignoreMap":128},[133,3157,3158,3160,3162,3164,3166,3168,3170],{"class":135,"line":136},[133,3159,164],{"class":139},[133,3161,144],{"class":143},[133,3163,170],{"class":169},[133,3165,174],{"class":173},[133,3167,177],{"class":169},[133,3169,180],{"class":173},[133,3171,183],{"class":169},[118,3173,187],{"id":186},[10,3175,190],{},[17,3177,3178,3180],{},[20,3179,195],{},[20,3181,198],{},[36,3183],{},[39,3185,204],{"id":203},[17,3187,3188,3192,3196],{},[20,3189,209,3190],{},[130,3191,212],{},[20,3193,215,3194],{},[130,3195,218],{},[20,3197,221],{},[123,3199,3200],{"className":224,"code":225,"language":226,"meta":128,"style":128},[130,3201,3202],{"__ignoreMap":128},[133,3203,3204,3206,3208],{"class":135,"line":136},[133,3205,127],{"class":233},[133,3207,236],{"class":173},[133,3209,239],{"class":173},[10,3211,242,3212],{},[244,3213,247],{"href":246},[39,3215,251],{"id":250},[17,3217,3218,3222],{},[20,3219,209,3220],{},[130,3221,258],{},[20,3223,221],{},[10,3225,242,3226],{},[244,3227,266],{"href":265},[36,3229],{},[39,3231,272],{"id":271},[17,3233,3234,3236,3238],{},[20,3235,277],{},[20,3237,280],{},[20,3239,283],{},[123,3241,3242],{"className":224,"code":286,"language":226,"meta":128,"style":128},[130,3243,3244],{"__ignoreMap":128},[133,3245,3246,3248,3250,3252],{"class":135,"line":136},[133,3247,293],{"class":233},[133,3249,296],{"class":173},[133,3251,299],{"class":173},[133,3253,302],{"class":173},[10,3255,242,3256],{},[244,3257,308],{"href":307},[36,3259],{},[39,3261,314],{"id":313},[17,3263,3264,3266,3268],{},[20,3265,319],{},[20,3267,322],{},[20,3269,325],{},[123,3271,3272],{"className":224,"code":328,"language":226,"meta":128,"style":128},[130,3273,3274],{"__ignoreMap":128},[133,3275,3276,3278,3280],{"class":135,"line":136},[133,3277,293],{"class":233},[133,3279,337],{"class":173},[133,3281,340],{"class":139},[36,3283],{},[39,3285,346],{"id":345},[10,3287,349],{},[10,3289,3290],{},[353,3291,355],{},[17,3293,3294],{},[20,3295,360],{},[10,3297,3298],{},[353,3299,365],{},[17,3301,3302,3304],{},[20,3303,370],{},[20,3305,373],{},[123,3307,3308],{"className":224,"code":376,"language":226,"meta":128,"style":128},[130,3309,3310],{"__ignoreMap":128},[133,3311,3312,3314,3316],{"class":135,"line":136},[133,3313,127],{"class":233},[133,3315,236],{"class":173},[133,3317,387],{"class":173},[39,3319,391],{"id":390},[10,3321,394,3322,401],{},[244,3323,400],{"href":397,"rel":3324},[399],[123,3326,3327],{"className":224,"code":404,"language":226,"meta":128,"style":128},[130,3328,3329],{"__ignoreMap":128},[133,3330,3331,3333,3335],{"class":135,"line":136},[133,3332,293],{"class":233},[133,3334,413],{"class":173},[133,3336,416],{"class":139},[10,3338,419],{},[17,3340,3341,3343],{},[20,3342,424],{},[20,3344,427],{},[39,3346,431],{"id":430},[10,3348,434,3349,438],{},[130,3350,437],{},[123,3352,3353],{"className":125,"code":441,"language":127,"meta":128,"style":128},[130,3354,3355,3363,3371,3379],{"__ignoreMap":128},[133,3356,3357,3359,3361],{"class":135,"line":136},[133,3358,448],{"class":139},[133,3360,144],{"class":143},[133,3362,453],{"class":139},[133,3364,3365,3367,3369],{"class":135,"line":456},[133,3366,459],{"class":139},[133,3368,144],{"class":143},[133,3370,453],{"class":139},[133,3372,3373,3375,3377],{"class":135,"line":466},[133,3374,469],{"class":139},[133,3376,144],{"class":143},[133,3378,453],{"class":139},[133,3380,3381,3383,3385],{"class":135,"line":476},[133,3382,479],{"class":139},[133,3384,144],{"class":143},[133,3386,453],{"class":139},[10,3388,486],{},[36,3390],{},[39,3392,492],{"id":491},[123,3394,3395],{"className":224,"code":495,"language":226,"meta":128,"style":128},[130,3396,3397,3409],{"__ignoreMap":128},[133,3398,3399,3401,3403,3405,3407],{"class":135,"line":136},[133,3400,293],{"class":233},[133,3402,504],{"class":173},[133,3404,507],{"class":139},[133,3406,510],{"class":173},[133,3408,513],{"class":173},[133,3410,3411,3413,3415,3417,3419],{"class":135,"line":456},[133,3412,293],{"class":233},[133,3414,520],{"class":173},[133,3416,507],{"class":139},[133,3418,525],{"class":139},[133,3420,513],{"class":173},[10,3422,530],{},[36,3424],{},[39,3426,536],{"id":535},[10,3428,539],{},[123,3430,3431],{"className":224,"code":542,"language":226,"meta":128,"style":128},[130,3432,3433,3443],{"__ignoreMap":128},[133,3434,3435,3437,3439,3441],{"class":135,"line":136},[133,3436,293],{"class":233},[133,3438,296],{"class":173},[133,3440,299],{"class":173},[133,3442,302],{"class":173},[133,3444,3445,3447,3449,3451],{"class":135,"line":456},[133,3446,293],{"class":233},[133,3448,296],{"class":173},[133,3450,299],{"class":173},[133,3452,565],{"class":173},[36,3454],{},[39,3456,571],{"id":570},[10,3458,574],{},[123,3460,3461],{"className":224,"code":577,"language":226,"meta":128,"style":128},[130,3462,3463,3471],{"__ignoreMap":128},[133,3464,3465,3467,3469],{"class":135,"line":136},[133,3466,584],{"class":233},[133,3468,587],{"class":139},[133,3470,302],{"class":173},[133,3472,3473,3475,3477,3479],{"class":135,"line":456},[133,3474,293],{"class":233},[133,3476,596],{"class":173},[133,3478,599],{"class":139},[133,3480,602],{"class":173},[10,3482,605],{},[39,3484,609],{"id":608},[10,3486,612],{},[123,3488,3489],{"className":615,"code":616,"language":617,"meta":128,"style":128},[130,3490,3491],{"__ignoreMap":128},[133,3492,3493],{"class":135,"line":136},[133,3494,616],{},[17,3496,3497,3499],{},[20,3498,628],{},[20,3500,631],{},[39,3502,635],{"id":634},[10,3504,355],{},[10,3506,3507,643],{},[130,3508,642],{},[10,3510,646],{},[10,3512,649],{},[39,3514,653],{"id":652},[10,3516,656],{},[123,3518,3519],{"className":224,"code":659,"language":226,"meta":128,"style":128},[130,3520,3521,3527,3537,3545,3553],{"__ignoreMap":128},[133,3522,3523,3525],{"class":135,"line":136},[133,3524,666],{"class":233},[133,3526,669],{"class":173},[133,3528,3529,3531,3533,3535],{"class":135,"line":456},[133,3530,674],{"class":233},[133,3532,677],{"class":173},[133,3534,680],{"class":139},[133,3536,683],{"class":173},[133,3538,3539,3541,3543],{"class":135,"line":466},[133,3540,127],{"class":233},[133,3542,236],{"class":173},[133,3544,387],{"class":173},[133,3546,3547,3549,3551],{"class":135,"line":476},[133,3548,127],{"class":233},[133,3550,236],{"class":173},[133,3552,239],{"class":173},[133,3554,3555,3557,3559,3561],{"class":135,"line":702},[133,3556,293],{"class":233},[133,3558,296],{"class":173},[133,3560,709],{"class":173},[133,3562,302],{"class":173},[36,3564],{},[39,3566,717],{"id":716},[36,3568],{},[118,3570,723],{"id":722},[10,3572,726],{},[118,3574,730],{"id":729},[10,3576,733],{},[118,3578,737],{"id":736},[10,3580,740],{},[118,3582,744],{"id":743},[10,3584,747],{},[118,3586,751],{"id":750},[10,3588,754],{},[36,3590],{},[758,3592,3593,3595],{"title":760,"type":761},[10,3594,764],{},[17,3596,3597,3601,3605,3609,3613,3617,3621,3625,3629],{},[20,3598,3599],{},[244,3600,308],{"href":307},[20,3602,3603],{},[244,3604,776],{"href":775},[20,3606,3607],{},[244,3608,782],{"href":781},[20,3610,3611],{},[244,3612,788],{"href":787},[20,3614,3615],{},[244,3616,794],{"href":793},[20,3618,3619],{},[244,3620,800],{"href":799},[20,3622,3623],{},[244,3624,805],{"href":246},[20,3626,3627],{},[244,3628,810],{"href":265},[20,3630,3631],{},[244,3632,816],{"href":815},[36,3634],{},[39,3636,822],{"id":821},[17,3638,3639,3643,3647,3651,3655],{},[20,3640,3641],{},[244,3642,308],{"href":307},[20,3644,3645],{},[244,3646,776],{"href":775},[20,3648,3649],{},[244,3650,788],{"href":787},[20,3652,3653],{},[244,3654,247],{"href":246},[20,3656,3657],{},[244,3658,266],{"href":265},[36,3660],{},[39,3662,850],{"id":849},[118,3664,854],{"id":853},[10,3666,857],{},[10,3668,860],{},[10,3670,863],{},[118,3672,867],{"id":866},[10,3674,870],{},[17,3676,3677,3679],{},[20,3678,875],{},[20,3680,878],{},[118,3682,882],{"id":881},[10,3684,885],{},[17,3686,3687,3689,3691,3693],{},[20,3688,890],{},[20,3690,893],{},[20,3692,896],{},[20,3694,899],{},[36,3696],{},[39,3698,905],{"id":904},[10,3700,908],{},[17,3702,3703,3705,3707],{},[20,3704,913],{},[20,3706,916],{},[20,3708,919],{},[36,3710],{},[10,3712,924],{},[10,3714,927],{},[929,3716,931],{},{"title":128,"searchDepth":466,"depth":466,"links":3718},[3719,3720,3725,3726,3727,3728,3729,3730,3731,3732,3733,3734,3735,3736,3737,3738,3745,3746,3751],{"id":41,"depth":456,"text":42},{"id":115,"depth":456,"text":116,"children":3721},[3722,3723,3724],{"id":120,"depth":466,"text":121},{"id":153,"depth":466,"text":154},{"id":186,"depth":466,"text":187},{"id":203,"depth":456,"text":204},{"id":250,"depth":456,"text":251},{"id":271,"depth":456,"text":272},{"id":313,"depth":456,"text":314},{"id":345,"depth":456,"text":346},{"id":390,"depth":456,"text":391},{"id":430,"depth":456,"text":431},{"id":491,"depth":456,"text":492},{"id":535,"depth":456,"text":536},{"id":570,"depth":456,"text":571},{"id":608,"depth":456,"text":609},{"id":634,"depth":456,"text":635},{"id":652,"depth":456,"text":653},{"id":716,"depth":456,"text":717,"children":3739},[3740,3741,3742,3743,3744],{"id":722,"depth":466,"text":723},{"id":729,"depth":466,"text":730},{"id":736,"depth":466,"text":737},{"id":743,"depth":466,"text":744},{"id":750,"depth":466,"text":751},{"id":821,"depth":456,"text":822},{"id":849,"depth":456,"text":850,"children":3747},[3748,3749,3750],{"id":853,"depth":466,"text":854},{"id":866,"depth":466,"text":867},{"id":881,"depth":466,"text":882},{"id":904,"depth":456,"text":905},{},[307,775,246,265,787],{"title":5,"description":968},[979,980,981],{"id":3757,"title":3758,"body":3759,"category":4441,"description":4442,"extension":969,"meta":4443,"navigation":54,"path":4444,"priority":972,"related":4445,"role":4446,"section":4447,"seo":4448,"stem":4449,"tags":4450,"__hash__":4452},"articles\u002Ffix-django-502-bad-gateway-step-by-step-guide.md","Fix Django 502 Bad Gateway (Nginx + Gunicorn) – Step-by-Step Guide",{"type":7,"value":3760,"toc":4419},[3761,3767,3770,3772,3776,3779,3814,3817,3820,3823,3825,3829,3832,3843,3846,3851,3853,3857,3860,3864,3878,3881,3894,3896,3899,3902,3917,3920,3922,3926,3949,3952,3963,3965,3969,3972,3985,3988,3997,4002,4005,4007,4011,4024,4027,4029,4032,4036,4048,4050,4054,4069,4073,4088,4090,4105,4107,4111,4125,4127,4131,4133,4137,4139,4163,4165,4169,4172,4177,4192,4197,4210,4212,4216,4218,4231,4234,4245,4247,4251,4254,4262,4264,4266,4271,4283,4285,4290,4304,4306,4311,4335,4339,4378,4380,4398,4400,4402,4416],[3762,3763,3764],"blockquote",{},[10,3765,3766],{},"Nginx cannot connect to your Django application (Gunicorn)",[10,3768,3769],{},"This guide walks you through exactly how to diagnose and fix it, step by step.",[36,3771],{},[39,3773,3775],{"id":3774},"quick-fix-try-this-first","⚡ Quick Fix (Try This First)",[10,3777,3778],{},"Run:",[123,3780,3782],{"className":224,"code":3781,"language":226,"meta":128,"style":128},"sudo systemctl status gunicorn\nsudo systemctl restart gunicorn\nsudo systemctl restart nginx\n",[130,3783,3784,3794,3804],{"__ignoreMap":128},[133,3785,3786,3788,3790,3792],{"class":135,"line":136},[133,3787,293],{"class":233},[133,3789,296],{"class":173},[133,3791,2492],{"class":173},[133,3793,302],{"class":173},[133,3795,3796,3798,3800,3802],{"class":135,"line":456},[133,3797,293],{"class":233},[133,3799,296],{"class":173},[133,3801,709],{"class":173},[133,3803,302],{"class":173},[133,3805,3806,3808,3810,3812],{"class":135,"line":466},[133,3807,293],{"class":233},[133,3809,296],{"class":173},[133,3811,709],{"class":173},[133,3813,565],{"class":173},[10,3815,3816],{},"Then reload your site.",[10,3818,3819],{},"👉 If it works, Gunicorn likely crashed or wasn’t running.",[10,3821,3822],{},"If not, continue below.",[36,3824],{},[39,3826,3828],{"id":3827},"what-a-502-bad-gateway-means","🧠 What a 502 Bad Gateway Means",[10,3830,3831],{},"In this setup:",[17,3833,3834,3837,3840],{},[20,3835,3836],{},"Nginx = web server",[20,3838,3839],{},"Gunicorn = application server",[20,3841,3842],{},"Django = your app",[10,3844,3845],{},"A 502 error means:",[3762,3847,3848],{},[10,3849,3850],{},"Nginx tried to forward a request → but Gunicorn didn’t respond",[36,3852],{},[39,3854,3856],{"id":3855},"step-by-step-diagnosis","🧪 Step-by-Step Diagnosis",[10,3858,3859],{},"Follow these steps in order. Don’t skip ahead.",[118,3861,3863],{"id":3862},"_1-check-if-gunicorn-is-running","1. Check if Gunicorn is running",[123,3865,3866],{"className":224,"code":2481,"language":226,"meta":128,"style":128},[130,3867,3868],{"__ignoreMap":128},[133,3869,3870,3872,3874,3876],{"class":135,"line":136},[133,3871,293],{"class":233},[133,3873,296],{"class":173},[133,3875,2492],{"class":173},[133,3877,302],{"class":173},[10,3879,3880],{},"Expected:",[123,3882,3884],{"className":224,"code":3883,"language":226,"meta":128,"style":128},"active (running)\n",[130,3885,3886],{"__ignoreMap":128},[133,3887,3888,3891],{"class":135,"line":136},[133,3889,3890],{"class":233},"active",[133,3892,3893],{"class":169}," (running)\n",[36,3895],{},[10,3897,3898],{},"If NOT running:",[10,3900,3901],{},"Start it:",[123,3903,3905],{"className":224,"code":3904,"language":226,"meta":128,"style":128},"sudo systemctl start gunicorn\n",[130,3906,3907],{"__ignoreMap":128},[133,3908,3909,3911,3913,3915],{"class":135,"line":136},[133,3910,293],{"class":233},[133,3912,296],{"class":173},[133,3914,2461],{"class":173},[133,3916,302],{"class":173},[10,3918,3919],{},"Then retry your site.",[36,3921],{},[118,3923,3925],{"id":3924},"_2-check-gunicorn-logs","2. Check Gunicorn logs",[123,3927,3929],{"className":224,"code":3928,"language":226,"meta":128,"style":128},"journalctl -u gunicorn --no-pager -n 50\n",[130,3930,3931],{"__ignoreMap":128},[133,3932,3933,3935,3937,3940,3943,3946],{"class":135,"line":136},[133,3934,584],{"class":233},[133,3936,587],{"class":139},[133,3938,3939],{"class":173}," gunicorn",[133,3941,3942],{"class":139}," --no-pager",[133,3944,3945],{"class":139}," -n",[133,3947,3948],{"class":139}," 50\n",[10,3950,3951],{},"Look for:",[17,3953,3954,3957,3960],{},[20,3955,3956],{},"Python errors",[20,3958,3959],{},"Import issues",[20,3961,3962],{},"Missing dependencies",[36,3964],{},[118,3966,3968],{"id":3967},"_3-check-gunicorn-socket-or-port","3. Check Gunicorn socket or port",[10,3970,3971],{},"If using a socket:",[123,3973,3975],{"className":224,"code":3974,"language":226,"meta":128,"style":128},"ls \u002Fvar\u002Fwww\u002Fmyproject\u002F\n",[130,3976,3977],{"__ignoreMap":128},[133,3978,3979,3982],{"class":135,"line":136},[133,3980,3981],{"class":233},"ls",[133,3983,3984],{"class":173}," \u002Fvar\u002Fwww\u002Fmyproject\u002F\n",[10,3986,3987],{},"You should see:",[123,3989,3991],{"className":615,"code":3990,"language":617,"meta":128,"style":128},"gunicorn.sock\n",[130,3992,3993],{"__ignoreMap":128},[133,3994,3995],{"class":135,"line":136},[133,3996,3990],{},[10,3998,3999],{},[353,4000,4001],{},"If missing:",[10,4003,4004],{},"Gunicorn failed to start properly → check logs again.",[36,4006],{},[118,4008,4010],{"id":4009},"_4-test-gunicorn-directly","4. Test Gunicorn directly",[123,4012,4014],{"className":224,"code":4013,"language":226,"meta":128,"style":128},"curl http:\u002F\u002F127.0.0.1:8000\n",[130,4015,4016],{"__ignoreMap":128},[133,4017,4018,4021],{"class":135,"line":136},[133,4019,4020],{"class":233},"curl",[133,4022,4023],{"class":173}," http:\u002F\u002F127.0.0.1:8000\n",[10,4025,4026],{},"OR (if using socket, skip this)",[36,4028],{},[10,4030,4031],{},"If this fails:\nProblem is in Django or Gunicorn (not Nginx)",[118,4033,4035],{"id":4034},"_5-check-nginx-configuration","5. Check Nginx configuration",[123,4037,4038],{"className":224,"code":328,"language":226,"meta":128,"style":128},[130,4039,4040],{"__ignoreMap":128},[133,4041,4042,4044,4046],{"class":135,"line":136},[133,4043,293],{"class":233},[133,4045,337],{"class":173},[133,4047,340],{"class":139},[36,4049],{},[10,4051,4052],{},[353,4053,3880],{},[123,4055,4057],{"className":615,"code":4056,"language":617,"meta":128,"style":128},"syntax is ok\ntest is successful\n",[130,4058,4059,4064],{"__ignoreMap":128},[133,4060,4061],{"class":135,"line":136},[133,4062,4063],{},"syntax is ok\n",[133,4065,4066],{"class":135,"line":456},[133,4067,4068],{},"test is successful\n",[118,4070,4072],{"id":4071},"_6-restart-nginx","6. Restart Nginx",[123,4074,4076],{"className":224,"code":4075,"language":226,"meta":128,"style":128},"sudo systemctl restart nginx\n",[130,4077,4078],{"__ignoreMap":128},[133,4079,4080,4082,4084,4086],{"class":135,"line":136},[133,4081,293],{"class":233},[133,4083,296],{"class":173},[133,4085,709],{"class":173},[133,4087,565],{"class":173},[36,4089],{},[123,4091,4093],{"className":224,"code":4092,"language":226,"meta":128,"style":128},"sudo tail -f \u002Fvar\u002Flog\u002Fnginx\u002Ferror.log\n",[130,4094,4095],{"__ignoreMap":128},[133,4096,4097,4099,4101,4103],{"class":135,"line":136},[133,4098,293],{"class":233},[133,4100,596],{"class":173},[133,4102,599],{"class":139},[133,4104,602],{"class":173},[36,4106],{},[118,4108,4110],{"id":4109},"_7-check-nginx-error-logs","7. Check Nginx error logs",[123,4112,4114],{"className":224,"code":4113,"language":226,"meta":128,"style":128},"tail -f \u002Fvar\u002Flog\u002Fnginx\u002Ferror.log\n",[130,4115,4116],{"__ignoreMap":128},[133,4117,4118,4121,4123],{"class":135,"line":136},[133,4119,4120],{"class":233},"tail",[133,4122,599],{"class":139},[133,4124,602],{"class":173},[36,4126],{},[39,4128,4130],{"id":4129},"common-causes-and-fixes","🔥 Common Causes (and Fixes)",[36,4132],{},[118,4134,4136],{"id":4135},"gunicorn-is-not-running","🔴 Gunicorn is not running",[10,4138,1701],{},[123,4140,4141],{"className":224,"code":2450,"language":226,"meta":128,"style":128},[130,4142,4143,4153],{"__ignoreMap":128},[133,4144,4145,4147,4149,4151],{"class":135,"line":136},[133,4146,293],{"class":233},[133,4148,296],{"class":173},[133,4150,2461],{"class":173},[133,4152,302],{"class":173},[133,4154,4155,4157,4159,4161],{"class":135,"line":456},[133,4156,293],{"class":233},[133,4158,296],{"class":173},[133,4160,299],{"class":173},[133,4162,302],{"class":173},[36,4164],{},[118,4166,4168],{"id":4167},"wrong-socket-path","🔴 Wrong socket path",[10,4170,4171],{},"Your Nginx config must match Gunicorn exactly:",[10,4173,4174],{},[353,4175,4176],{},"Nginx:",[123,4178,4180],{"className":224,"code":4179,"language":226,"meta":128,"style":128},"proxy_pass http:\u002F\u002Funix:\u002Fvar\u002Fwww\u002Fmyproject\u002Fgunicorn.sock;\n",[130,4181,4182],{"__ignoreMap":128},[133,4183,4184,4187,4190],{"class":135,"line":136},[133,4185,4186],{"class":233},"proxy_pass",[133,4188,4189],{"class":173}," http:\u002F\u002Funix:\u002Fvar\u002Fwww\u002Fmyproject\u002Fgunicorn.sock",[133,4191,1484],{"class":169},[10,4193,4194],{},[353,4195,4196],{},"Gunicorn:",[123,4198,4200],{"className":224,"code":4199,"language":226,"meta":128,"style":128},"--bind unix:\u002Fvar\u002Fwww\u002Fmyproject\u002Fgunicorn.sock\n",[130,4201,4202],{"__ignoreMap":128},[133,4203,4204,4207],{"class":135,"line":136},[133,4205,4206],{"class":233},"--bind",[133,4208,4209],{"class":173}," unix:\u002Fvar\u002Fwww\u002Fmyproject\u002Fgunicorn.sock\n",[36,4211],{},[118,4213,4215],{"id":4214},"gunicorn-crashed-on-startup","🔴 Gunicorn crashed on startup",[10,4217,365],{},[123,4219,4221],{"className":224,"code":4220,"language":226,"meta":128,"style":128},"journalctl -u gunicorn\n",[130,4222,4223],{"__ignoreMap":128},[133,4224,4225,4227,4229],{"class":135,"line":136},[133,4226,584],{"class":233},[133,4228,587],{"class":139},[133,4230,302],{"class":173},[10,4232,4233],{},"Common causes:",[17,4235,4236,4239,4242],{},[20,4237,4238],{},"Missing packages",[20,4240,4241],{},"Django errors",[20,4243,4244],{},"Wrong settings module",[36,4246],{},[118,4248,4250],{"id":4249},"nginx-cannot-access-socket","🔴 Nginx cannot access socket",[10,4252,4253],{},"Fix permissions and ensure:",[17,4255,4256,4259],{},[20,4257,4258],{},"Same user\u002Fgroup",[20,4260,4261],{},"Correct file ownership",[36,4263],{},[39,4265,1794],{"id":1793},[10,4267,4268],{},[353,4269,4270],{},"Check Gunicorn logs:",[123,4272,4273],{"className":224,"code":4220,"language":226,"meta":128,"style":128},[130,4274,4275],{"__ignoreMap":128},[133,4276,4277,4279,4281],{"class":135,"line":136},[133,4278,584],{"class":233},[133,4280,587],{"class":139},[133,4282,302],{"class":173},[36,4284],{},[10,4286,4287],{},[353,4288,4289],{},"Check Nginx logs:",[123,4291,4292],{"className":224,"code":4092,"language":226,"meta":128,"style":128},[130,4293,4294],{"__ignoreMap":128},[133,4295,4296,4298,4300,4302],{"class":135,"line":136},[133,4297,293],{"class":233},[133,4299,596],{"class":173},[133,4301,599],{"class":139},[133,4303,602],{"class":173},[36,4305],{},[10,4307,4308],{},[353,4309,4310],{},"Restart everything cleanly:",[123,4312,4313],{"className":224,"code":2802,"language":226,"meta":128,"style":128},[130,4314,4315,4325],{"__ignoreMap":128},[133,4316,4317,4319,4321,4323],{"class":135,"line":136},[133,4318,293],{"class":233},[133,4320,296],{"class":173},[133,4322,709],{"class":173},[133,4324,302],{"class":173},[133,4326,4327,4329,4331,4333],{"class":135,"line":456},[133,4328,293],{"class":233},[133,4330,296],{"class":173},[133,4332,709],{"class":173},[133,4334,565],{"class":173},[39,4336,4338],{"id":4337},"quick-fix-checklist","✅ Quick Fix Checklist",[17,4340,4342,4348,4354,4360,4366,4372],{"className":4341},[46],[20,4343,4345,4347],{"className":4344},[50],[52,4346],{"disabled":54,"type":55}," Gunicorn is running",[20,4349,4351,4353],{"className":4350},[50],[52,4352],{"disabled":54,"type":55}," No errors in Gunicorn logs",[20,4355,4357,4359],{"className":4356},[50],[52,4358],{"disabled":54,"type":55}," Socket file exists",[20,4361,4363,4365],{"className":4362},[50],[52,4364],{"disabled":54,"type":55}," Nginx config is valid",[20,4367,4369,4371],{"className":4368},[50],[52,4370],{"disabled":54,"type":55}," Permissions are correct",[20,4373,4375,4377],{"className":4374},[50],[52,4376],{"disabled":54,"type":55}," Django app runs locally",[36,4379],{},[758,4381,4384],{"title":4382,"type":4383},"Need to narrow down the exact 502 cause?","warning",[10,4385,4386,4387,177,4390,4393,4394,4397],{},"Check the targeted fixes for ",[244,4388,4389],{"href":793},"connection refused",[244,4391,4392],{"href":799},"socket permission denied",", and the full ",[244,4395,4396],{"href":307},"deploy guide",".",[36,4399],{},[39,4401,822],{"id":821},[17,4403,4404,4408,4412],{},[20,4405,4406],{},[244,4407,794],{"href":793},[20,4409,4410],{},[244,4411,800],{"href":799},[20,4413,4414],{},[244,4415,308],{"href":307},[929,4417,4418],{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":128,"searchDepth":466,"depth":466,"links":4420},[4421,4422,4423,4432,4438,4439,4440],{"id":3774,"depth":456,"text":3775},{"id":3827,"depth":456,"text":3828},{"id":3855,"depth":456,"text":3856,"children":4424},[4425,4426,4427,4428,4429,4430,4431],{"id":3862,"depth":466,"text":3863},{"id":3924,"depth":466,"text":3925},{"id":3967,"depth":466,"text":3968},{"id":4009,"depth":466,"text":4010},{"id":4034,"depth":466,"text":4035},{"id":4071,"depth":466,"text":4072},{"id":4109,"depth":466,"text":4110},{"id":4129,"depth":456,"text":4130,"children":4433},[4434,4435,4436,4437],{"id":4135,"depth":466,"text":4136},{"id":4167,"depth":466,"text":4168},{"id":4214,"depth":466,"text":4215},{"id":4249,"depth":466,"text":4250},{"id":1793,"depth":456,"text":1794},{"id":4337,"depth":456,"text":4338},{"id":821,"depth":456,"text":822},"Troubleshooting","If you're seeing a 502 Bad Gateway error when deploying Django with Nginx and Gunicorn, it usually means:",{},"\u002Ffix-django-502-bad-gateway-step-by-step-guide",[793,799,307],"fix","fix-issues",{"title":3758,"description":4442},"fix-django-502-bad-gateway-step-by-step-guide",[979,1463,2302,4451],"deployment","6D9xdSpheDl3TqFjsdNilUR3mWtmjMR-azgLeWpO_ZE",{"id":4454,"title":4455,"body":4456,"category":5177,"description":5178,"extension":969,"meta":5179,"navigation":54,"path":5180,"priority":5181,"related":5182,"role":4446,"section":4447,"seo":5183,"stem":5184,"tags":5185,"__hash__":5187},"articles\u002Fdjango-media-files-not-serving-uploads-broken.md","Fix Django Media Files Not Serving (Uploads Broken in Production)",{"type":7,"value":4457,"toc":5144},[4458,4461,4472,4475,4478,4480,4482,4484,4508,4511,4520,4523,4525,4529,4532,4540,4543,4548,4550,4552,4555,4562,4566,4590,4593,4597,4609,4611,4616,4619,4627,4631,4634,4642,4647,4652,4657,4662,4666,4669,4681,4684,4687,4713,4716,4727,4731,4743,4746,4760,4764,4792,4795,4797,4799,4801,4805,4807,4820,4824,4826,4848,4852,4854,4870,4874,4877,4880,4884,4897,4899,4901,4905,4919,4923,4931,4935,4952,4956,4966,4982,4984,5022,5024,5038,5040,5042,5056,5058,5060,5064,5072,5076,5079,5092,5094,5097,5101,5104,5112,5114,5117,5120,5131,5134,5136,5138,5141],[10,4459,4460],{},"If your Django app uploads files successfully but:",[17,4462,4463,4466,4469],{},[20,4464,4465],{},"Images don’t load",[20,4467,4468],{},"User uploads return 404",[20,4470,4471],{},"Media URLs are broken",[10,4473,4474],{},"👉 Then your media files are not being served correctly",[10,4476,4477],{},"This guide will walk you through how to fix it step-by-step.",[36,4479],{},[39,4481,3775],{"id":3774},[10,4483,3778],{},[123,4485,4486],{"className":224,"code":2802,"language":226,"meta":128,"style":128},[130,4487,4488,4498],{"__ignoreMap":128},[133,4489,4490,4492,4494,4496],{"class":135,"line":136},[133,4491,293],{"class":233},[133,4493,296],{"class":173},[133,4495,709],{"class":173},[133,4497,302],{"class":173},[133,4499,4500,4502,4504,4506],{"class":135,"line":456},[133,4501,293],{"class":233},[133,4503,296],{"class":173},[133,4505,709],{"class":173},[133,4507,565],{"class":173},[10,4509,4510],{},"Then check a media file URL:",[123,4512,4514],{"className":615,"code":4513,"language":617,"meta":128,"style":128},"http:\u002F\u002Fyour-domain\u002Fmedia\u002Fyour-file.jpg\n",[130,4515,4516],{"__ignoreMap":128},[133,4517,4518],{"class":135,"line":136},[133,4519,4513],{},[10,4521,4522],{},"👉 If still broken, continue below.",[36,4524],{},[39,4526,4528],{"id":4527},"whats-happening","🧠 What’s Happening",[10,4530,4531],{},"In production:",[17,4533,4534,4537],{},[20,4535,4536],{},"Django does NOT serve media files",[20,4538,4539],{},"Nginx must serve them",[10,4541,4542],{},"If uploads are broken, it usually means:",[3762,4544,4545],{},[10,4546,4547],{},"Nginx cannot find or access your media directory",[36,4549],{},[39,4551,3856],{"id":3855},[10,4553,4554],{},"Follow these steps in order.",[118,4556,4558,4559,4561],{"id":4557},"_1-check-media_root-setting","1. Check ",[130,4560,258],{}," setting",[10,4563,434,4564,438],{},[130,4565,437],{},[123,4567,4569],{"className":125,"code":4568,"language":127,"meta":128,"style":128},"MEDIA_ROOT = '\u002Fvar\u002Fwww\u002Fmyproject\u002Fmedia\u002F'\nMEDIA_URL = '\u002Fmedia\u002F'\n",[130,4570,4571,4580],{"__ignoreMap":128},[133,4572,4573,4575,4577],{"class":135,"line":136},[133,4574,258],{"class":139},[133,4576,144],{"class":143},[133,4578,4579],{"class":173}," '\u002Fvar\u002Fwww\u002Fmyproject\u002Fmedia\u002F'\n",[133,4581,4582,4585,4587],{"class":135,"line":456},[133,4583,4584],{"class":139},"MEDIA_URL",[133,4586,144],{"class":143},[133,4588,4589],{"class":173}," '\u002Fmedia\u002F'\n",[10,4591,4592],{},"👉 This defines where uploaded files are stored",[118,4594,4596],{"id":4595},"_2-verify-files-exist","2. Verify files exist",[123,4598,4600],{"className":224,"code":4599,"language":226,"meta":128,"style":128},"ls \u002Fvar\u002Fwww\u002Fmyproject\u002Fmedia\u002F\n",[130,4601,4602],{"__ignoreMap":128},[133,4603,4604,4606],{"class":135,"line":136},[133,4605,3981],{"class":233},[133,4607,4608],{"class":173}," \u002Fvar\u002Fwww\u002Fmyproject\u002Fmedia\u002F\n",[10,4610,3987],{},[17,4612,4613],{},[20,4614,4615],{},"Uploaded images\u002Ffiles",[10,4617,4618],{},"👉 If empty:",[17,4620,4621,4624],{},[20,4622,4623],{},"If not, then uploads are not working. Check your upload code.",[20,4625,4626],{},"Upload process is broken (not Nginx)",[118,4628,4630],{"id":4629},"_3-test-media-url-directly","3. Test media URL directly",[10,4632,4633],{},"Open in browser:",[123,4635,4636],{"className":615,"code":4513,"language":617,"meta":128,"style":128},[130,4637,4638],{"__ignoreMap":128},[133,4639,4640],{"class":135,"line":136},[133,4641,4513],{},[10,4643,4644],{},[353,4645,4646],{},"If 404:",[17,4648,4649],{},[20,4650,4651],{},"Nginx is not serving media",[10,4653,4654],{},[353,4655,4656],{},"If works:",[17,4658,4659],{},[20,4660,4661],{},"Problem is elsewhere (templates, paths)",[118,4663,4665],{"id":4664},"_4-check-nginx-configuration","4. Check Nginx configuration",[10,4667,4668],{},"Open config:",[123,4670,4671],{"className":224,"code":2533,"language":226,"meta":128,"style":128},[130,4672,4673],{"__ignoreMap":128},[133,4674,4675,4677,4679],{"class":135,"line":136},[133,4676,293],{"class":233},[133,4678,2542],{"class":173},[133,4680,2545],{"class":173},[10,4682,4683],{},"or your favorite editor.",[10,4685,4686],{},"Ensure this exists:",[123,4688,4690],{"className":1461,"code":4689,"language":1463,"meta":128,"style":128},"location \u002Fmedia\u002F {\n    root \u002Fvar\u002Fwww\u002Fmyproject;\n}\n",[130,4691,4692,4702,4709],{"__ignoreMap":128},[133,4693,4694,4697,4700],{"class":135,"line":136},[133,4695,4696],{"class":143},"location",[133,4698,4699],{"class":233}," \u002Fmedia\u002F ",[133,4701,1499],{"class":169},[133,4703,4704,4707],{"class":135,"line":456},[133,4705,4706],{"class":143},"    root ",[133,4708,2600],{"class":169},[133,4710,4711],{"class":135,"line":466},[133,4712,1557],{"class":169},[10,4714,4715],{},"👉 Important:",[17,4717,4718],{},[20,4719,4720,4723,4724],{},[130,4721,4722],{},"\u002Fmedia\u002F"," maps to ",[130,4725,4726],{},"\u002Fvar\u002Fwww\u002Fmyproject\u002Fmedia\u002F",[118,4728,4730],{"id":4729},"_5-test-nginx-config","5. Test Nginx config",[123,4732,4733],{"className":224,"code":328,"language":226,"meta":128,"style":128},[130,4734,4735],{"__ignoreMap":128},[133,4736,4737,4739,4741],{"class":135,"line":136},[133,4738,293],{"class":233},[133,4740,337],{"class":173},[133,4742,340],{"class":139},[10,4744,4745],{},"Then:",[123,4747,4748],{"className":224,"code":4075,"language":226,"meta":128,"style":128},[130,4749,4750],{"__ignoreMap":128},[133,4751,4752,4754,4756,4758],{"class":135,"line":136},[133,4753,293],{"class":233},[133,4755,296],{"class":173},[133,4757,709],{"class":173},[133,4759,565],{"class":173},[118,4761,4763],{"id":4762},"_6-check-file-permissions","6. Check file permissions",[123,4765,4766],{"className":224,"code":495,"language":226,"meta":128,"style":128},[130,4767,4768,4780],{"__ignoreMap":128},[133,4769,4770,4772,4774,4776,4778],{"class":135,"line":136},[133,4771,293],{"class":233},[133,4773,504],{"class":173},[133,4775,507],{"class":139},[133,4777,510],{"class":173},[133,4779,513],{"class":173},[133,4781,4782,4784,4786,4788,4790],{"class":135,"line":456},[133,4783,293],{"class":233},[133,4785,520],{"class":173},[133,4787,507],{"class":139},[133,4789,525],{"class":139},[133,4791,513],{"class":173},[10,4793,4794],{},"👉 Nginx must be able to read media files",[36,4796],{},[39,4798,4130],{"id":4129},[36,4800],{},[118,4802,4804],{"id":4803},"media_root-is-incorrect","🔴 MEDIA_ROOT is incorrect",[10,4806,1701],{},[123,4808,4810],{"className":224,"code":4809,"language":226,"meta":128,"style":128},"MEDIA_ROOT = '\u002Fvar\u002Fwww\u002Fmyproject\u002Fmedia\u002F'\n",[130,4811,4812],{"__ignoreMap":128},[133,4813,4814,4816,4818],{"class":135,"line":136},[133,4815,258],{"class":233},[133,4817,144],{"class":173},[133,4819,4579],{"class":173},[118,4821,4823],{"id":4822},"nginx-not-configured-for-media","🔴 Nginx not configured for media",[10,4825,1458],{},[123,4827,4828],{"className":1461,"code":4689,"language":1463,"meta":128,"style":128},[130,4829,4830,4838,4844],{"__ignoreMap":128},[133,4831,4832,4834,4836],{"class":135,"line":136},[133,4833,4696],{"class":143},[133,4835,4699],{"class":233},[133,4837,1499],{"class":169},[133,4839,4840,4842],{"class":135,"line":456},[133,4841,4706],{"class":143},[133,4843,2600],{"class":169},[133,4845,4846],{"class":135,"line":466},[133,4847,1557],{"class":169},[118,4849,4851],{"id":4850},"permissions-issue","🔴 Permissions issue",[10,4853,1701],{},[123,4855,4856],{"className":224,"code":2848,"language":226,"meta":128,"style":128},[130,4857,4858],{"__ignoreMap":128},[133,4859,4860,4862,4864,4866,4868],{"class":135,"line":136},[133,4861,293],{"class":233},[133,4863,504],{"class":173},[133,4865,507],{"class":139},[133,4867,510],{"class":173},[133,4869,513],{"class":173},[118,4871,4873],{"id":4872},"files-stored-in-wrong-location","🔴 Files stored in wrong location",[10,4875,4876],{},"Check upload path:",[10,4878,4879],{},"Django might be saving elsewhere",[118,4881,4883],{"id":4882},"media_url-incorrect","🔴 MEDIA_URL incorrect",[123,4885,4887],{"className":125,"code":4886,"language":127,"meta":128,"style":128},"MEDIA_URL = '\u002Fmedia\u002F'\n",[130,4888,4889],{"__ignoreMap":128},[133,4890,4891,4893,4895],{"class":135,"line":136},[133,4892,4584],{"class":139},[133,4894,144],{"class":143},[133,4896,4589],{"class":173},[36,4898],{},[39,4900,1794],{"id":1793},[118,4902,4904],{"id":4903},"check-nginx-logs","Check Nginx logs",[123,4906,4907],{"className":224,"code":4092,"language":226,"meta":128,"style":128},[130,4908,4909],{"__ignoreMap":128},[133,4910,4911,4913,4915,4917],{"class":135,"line":136},[133,4912,293],{"class":233},[133,4914,596],{"class":173},[133,4916,599],{"class":139},[133,4918,602],{"class":173},[10,4920,4921],{},[353,4922,3951],{},[17,4924,4925,4928],{},[20,4926,4927],{},"404",[20,4929,4930],{},"permission denied",[118,4932,4934],{"id":4933},"check-browser-devtools","Check browser DevTools",[17,4936,4937,4940],{},[20,4938,4939],{},"Network tab → failed requests",[20,4941,4942,4944],{},[353,4943,3951],{},[17,4945,4946,4949],{},[20,4947,4948],{},"404 errors",[20,4950,4951],{},"incorrect URLs",[118,4953,4955],{"id":4954},"check-django-upload-path","Check Django upload path",[10,4957,4958,4959,4962,4963,438],{},"If using ",[130,4960,4961],{},"ImageField"," or ",[130,4964,4965],{},"FileField",[123,4967,4969],{"className":125,"code":4968,"language":127,"meta":128,"style":128},"upload_to='uploads\u002F'\n",[130,4970,4971],{"__ignoreMap":128},[133,4972,4973,4976,4979],{"class":135,"line":136},[133,4974,4975],{"class":169},"upload_to",[133,4977,4978],{"class":143},"=",[133,4980,4981],{"class":173},"'uploads\u002F'\n",[39,4983,4338],{"id":4337},[17,4985,4987,4993,4999,5005,5011,5016],{"className":4986},[46],[20,4988,4990,4992],{"className":4989},[50],[52,4991],{"disabled":54,"type":55}," MEDIA_ROOT is correct",[20,4994,4996,4998],{"className":4995},[50],[52,4997],{"disabled":54,"type":55}," MEDIA_URL is \u002Fmedia\u002F",[20,5000,5002,5004],{"className":5001},[50],[52,5003],{"disabled":54,"type":55}," Files exist in media folder",[20,5006,5008,5010],{"className":5007},[50],[52,5009],{"disabled":54,"type":55}," Nginx config includes \u002Fmedia\u002F",[20,5012,5014,4371],{"className":5013},[50],[52,5015],{"disabled":54,"type":55},[20,5017,5019,5021],{"className":5018},[50],[52,5020],{"disabled":54,"type":55}," Nginx restarted",[36,5023],{},[758,5025,5028],{"title":5026,"type":5027},"Still fixing the file-serving layer?","info",[10,5029,5030,5031,5034,5035,5037],{},"Verify your ",[244,5032,5033],{"href":246},"static files setup"," and compare it against the full ",[244,5036,4396],{"href":307}," so both Nginx mappings stay aligned.",[36,5039],{},[39,5041,822],{"id":821},[17,5043,5044,5048,5052],{},[20,5045,5046],{},[244,5047,247],{"href":246},[20,5049,5050],{},[244,5051,308],{"href":307},[20,5053,5054],{},[244,5055,788],{"href":787},[36,5057],{},[39,5059,850],{"id":849},[118,5061,5063],{"id":5062},"whats-the-difference-between-static-and-media-files","What’s the difference between static and media files?",[17,5065,5066,5069],{},[20,5067,5068],{},"Static: CSS, JS (part of your code)",[20,5070,5071],{},"Media: user uploads (dynamic content)",[118,5073,5075],{"id":5074},"can-django-serve-media-files","Can Django serve media files?",[10,5077,5078],{},"Only in development:",[123,5080,5082],{"className":125,"code":5081,"language":127,"meta":128,"style":128},"DEBUG = True\n",[130,5083,5084],{"__ignoreMap":128},[133,5085,5086,5088,5090],{"class":135,"line":136},[133,5087,140],{"class":139},[133,5089,144],{"class":143},[133,5091,453],{"class":139},[10,5093,4531],{},[10,5095,5096],{},"👉 Use Nginx or a CDN to serve media files for better performance and security.",[118,5098,5100],{"id":5099},"why-do-uploads-work-but-files-dont-load","Why do uploads work but files don’t load?",[10,5102,5103],{},"Because:",[17,5105,5106,5109],{},[20,5107,5108],{},"Files are saved",[20,5110,5111],{},"But not served by Nginx",[39,5113,905],{"id":904},[10,5115,5116],{},"If media files are broken:",[10,5118,5119],{},"It’s almost always:",[17,5121,5122,5125,5128],{},[20,5123,5124],{},"Nginx config",[20,5126,5127],{},"File permissions",[20,5129,5130],{},"MEDIA_ROOT mismatch",[10,5132,5133],{},"Fix those, and uploads will work correctly.",[36,5135],{},[10,5137,924],{},[10,5139,5140],{},"A repeatable, pre-tested setup will save hours of debugging.",[929,5142,5143],{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}",{"title":128,"searchDepth":466,"depth":466,"links":5145},[5146,5147,5148,5157,5164,5169,5170,5171,5176],{"id":3774,"depth":456,"text":3775},{"id":4527,"depth":456,"text":4528},{"id":3855,"depth":456,"text":3856,"children":5149},[5150,5152,5153,5154,5155,5156],{"id":4557,"depth":466,"text":5151},"1. Check MEDIA_ROOT setting",{"id":4595,"depth":466,"text":4596},{"id":4629,"depth":466,"text":4630},{"id":4664,"depth":466,"text":4665},{"id":4729,"depth":466,"text":4730},{"id":4762,"depth":466,"text":4763},{"id":4129,"depth":456,"text":4130,"children":5158},[5159,5160,5161,5162,5163],{"id":4803,"depth":466,"text":4804},{"id":4822,"depth":466,"text":4823},{"id":4850,"depth":466,"text":4851},{"id":4872,"depth":466,"text":4873},{"id":4882,"depth":466,"text":4883},{"id":1793,"depth":456,"text":1794,"children":5165},[5166,5167,5168],{"id":4903,"depth":466,"text":4904},{"id":4933,"depth":466,"text":4934},{"id":4954,"depth":466,"text":4955},{"id":4337,"depth":456,"text":4338},{"id":821,"depth":456,"text":822},{"id":849,"depth":456,"text":850,"children":5172},[5173,5174,5175],{"id":5062,"depth":466,"text":5063},{"id":5074,"depth":466,"text":5075},{"id":5099,"depth":466,"text":5100},{"id":904,"depth":456,"text":905},"Media","Troubleshooting guide to fix Django media files not serving in production. Learn how to configure media root, Nginx mappings, and permissions to resolve upload issues.",{},"\u002Fdjango-media-files-not-serving-uploads-broken","5",[307,1897,246],{"title":4455,"description":5178},"django-media-files-not-serving-uploads-broken",[979,5186,980],"media-files","8kZwUs2sh4lK7HDFbO_B3Bo0DYEfm3SwqRs3onmoT-Y",{"id":5189,"title":5190,"body":5191,"category":5828,"description":5829,"extension":969,"meta":5830,"navigation":54,"path":5831,"priority":5832,"related":5833,"role":4446,"section":4447,"seo":5834,"stem":5835,"tags":5836,"__hash__":5838},"articles\u002Fdjango-static-files-not-loading-in-production.md","Fix Django Static Files Not Loading in Production (Nginx + Gunicorn)",{"type":7,"value":5192,"toc":5801},[5193,5196,5207,5210,5213,5215,5217,5219,5252,5254,5257,5259,5261,5263,5271,5274,5279,5281,5283,5285,5290,5294,5306,5309,5311,5318,5330,5333,5345,5347,5364,5367,5371,5374,5386,5389,5391,5414,5416,5431,5433,5437,5449,5451,5465,5467,5471,5473,5482,5487,5492,5497,5502,5504,5506,5534,5537,5540,5542,5544,5550,5552,5564,5570,5573,5581,5585,5588,5601,5604,5615,5619,5621,5633,5636,5638,5640,5656,5660,5662,5675,5677,5679,5693,5695,5701,5704,5719,5721,5723,5769,5780,5782,5784,5799],[10,5194,5195],{},"If your Django site loads but:",[17,5197,5198,5201,5204],{},[20,5199,5200],{},"CSS is missing",[20,5202,5203],{},"JavaScript is broken",[20,5205,5206],{},"Admin panel looks unstyled",[10,5208,5209],{},"👉 Then your static files are not being served correctly",[10,5211,5212],{},"This guide will help you fix it step-by-step.",[36,5214],{},[39,5216,3775],{"id":3774},[10,5218,3778],{},[123,5220,5222],{"className":224,"code":5221,"language":226,"meta":128,"style":128},"python manage.py collectstatic\nsudo systemctl restart gunicorn\nsudo systemctl restart nginx\n",[130,5223,5224,5232,5242],{"__ignoreMap":128},[133,5225,5226,5228,5230],{"class":135,"line":136},[133,5227,127],{"class":233},[133,5229,236],{"class":173},[133,5231,239],{"class":173},[133,5233,5234,5236,5238,5240],{"class":135,"line":456},[133,5235,293],{"class":233},[133,5237,296],{"class":173},[133,5239,709],{"class":173},[133,5241,302],{"class":173},[133,5243,5244,5246,5248,5250],{"class":135,"line":466},[133,5245,293],{"class":233},[133,5247,296],{"class":173},[133,5249,709],{"class":173},[133,5251,565],{"class":173},[10,5253,3816],{},[10,5255,5256],{},"👉 This solves the issue in many cases.",[36,5258],{},[39,5260,4528],{"id":4527},[10,5262,4531],{},[17,5264,5265,5268],{},[20,5266,5267],{},"Django does NOT serve static files",[20,5269,5270],{},"Nginx is responsible for serving them",[10,5272,5273],{},"If static files are broken, it usually means:",[3762,5275,5276],{},[10,5277,5278],{},"Nginx cannot find or access your static files",[36,5280],{},[39,5282,3856],{"id":3855},[10,5284,4554],{},[118,5286,4558,5288,4561],{"id":5287},"_1-check-static_root-setting",[130,5289,212],{},[10,5291,434,5292,438],{},[130,5293,437],{},[123,5295,5296],{"className":125,"code":2695,"language":127,"meta":128,"style":128},[130,5297,5298],{"__ignoreMap":128},[133,5299,5300,5302,5304],{"class":135,"line":136},[133,5301,212],{"class":139},[133,5303,144],{"class":143},[133,5305,2706],{"class":173},[10,5307,5308],{},"👉 This is where files will be collected",[36,5310],{},[118,5312,5314,5315,5317],{"id":5313},"_2-run-collectstatic-command","2. Run ",[130,5316,218],{}," command",[123,5319,5320],{"className":224,"code":225,"language":226,"meta":128,"style":128},[130,5321,5322],{"__ignoreMap":128},[133,5323,5324,5326,5328],{"class":135,"line":136},[133,5325,127],{"class":233},[133,5327,236],{"class":173},[133,5329,239],{"class":173},[10,5331,5332],{},"Verify files exist:",[123,5334,5336],{"className":224,"code":5335,"language":226,"meta":128,"style":128},"ls \u002Fvar\u002Fwww\u002Fmyproject\u002Fstatic\u002F\n",[130,5337,5338],{"__ignoreMap":128},[133,5339,5340,5342],{"class":135,"line":136},[133,5341,3981],{"class":233},[133,5343,5344],{"class":173}," \u002Fvar\u002Fwww\u002Fmyproject\u002Fstatic\u002F\n",[10,5346,3987],{},[17,5348,5349,5354,5359],{},[20,5350,5351],{},[130,5352,5353],{},"admin\u002F",[20,5355,5356],{},[130,5357,5358],{},"css\u002F",[20,5360,5361],{},[130,5362,5363],{},"js\u002F",[10,5365,5366],{},"👉 If empty → static files were not collected",[118,5368,5370],{"id":5369},"_3-check-nginx-configuration","3. Check Nginx configuration",[10,5372,5373],{},"Open your config:",[123,5375,5376],{"className":224,"code":2533,"language":226,"meta":128,"style":128},[130,5377,5378],{"__ignoreMap":128},[133,5379,5380,5382,5384],{"class":135,"line":136},[133,5381,293],{"class":233},[133,5383,2542],{"class":173},[133,5385,2545],{"class":173},[10,5387,5388],{},"or your favourite editor.",[10,5390,4686],{},[123,5392,5394],{"className":1461,"code":5393,"language":1463,"meta":128,"style":128},"location \u002Fstatic\u002F {\n    root \u002Fvar\u002Fwww\u002Fmyproject;\n}\n",[130,5395,5396,5404,5410],{"__ignoreMap":128},[133,5397,5398,5400,5402],{"class":135,"line":136},[133,5399,4696],{"class":143},[133,5401,1496],{"class":233},[133,5403,1499],{"class":169},[133,5405,5406,5408],{"class":135,"line":456},[133,5407,4706],{"class":143},[133,5409,2600],{"class":169},[133,5411,5412],{"class":135,"line":466},[133,5413,1557],{"class":169},[10,5415,4715],{},[10,5417,5418,5421,5422,5424,5425,4723,5428],{},[130,5419,5420],{},"root"," must match your ",[130,5423,212],{}," parent directory\n",[130,5426,5427],{},"\u002Fstatic\u002F",[130,5429,5430],{},"\u002Fvar\u002Fwww\u002Fmyproject\u002Fstatic\u002F",[36,5432],{},[118,5434,5436],{"id":5435},"_4-test-nginx-config","4. Test Nginx config",[123,5438,5439],{"className":224,"code":328,"language":226,"meta":128,"style":128},[130,5440,5441],{"__ignoreMap":128},[133,5442,5443,5445,5447],{"class":135,"line":136},[133,5444,293],{"class":233},[133,5446,337],{"class":173},[133,5448,340],{"class":139},[10,5450,4745],{},[123,5452,5453],{"className":224,"code":4075,"language":226,"meta":128,"style":128},[130,5454,5455],{"__ignoreMap":128},[133,5456,5457,5459,5461,5463],{"class":135,"line":136},[133,5458,293],{"class":233},[133,5460,296],{"class":173},[133,5462,709],{"class":173},[133,5464,565],{"class":173},[36,5466],{},[118,5468,5470],{"id":5469},"_5-test-static-file-directly","5. Test static file directly",[10,5472,4633],{},[123,5474,5476],{"className":224,"code":5475,"language":226,"meta":128,"style":128},"http:\u002F\u002Fyour-domain\u002Fstatic\u002Fadmin\u002Fcss\u002Fbase.css\n",[130,5477,5478],{"__ignoreMap":128},[133,5479,5480],{"class":135,"line":136},[133,5481,5475],{"class":233},[10,5483,5484],{},[353,5485,5486],{},"If it works:",[17,5488,5489],{},[20,5490,5491],{},"Nginx is correct",[10,5493,5494],{},[353,5495,5496],{},"If NOT:",[17,5498,5499],{},[20,5500,5501],{},"Problem is Nginx or file path",[36,5503],{},[118,5505,4763],{"id":4762},[123,5507,5508],{"className":224,"code":495,"language":226,"meta":128,"style":128},[130,5509,5510,5522],{"__ignoreMap":128},[133,5511,5512,5514,5516,5518,5520],{"class":135,"line":136},[133,5513,293],{"class":233},[133,5515,504],{"class":173},[133,5517,507],{"class":139},[133,5519,510],{"class":173},[133,5521,513],{"class":173},[133,5523,5524,5526,5528,5530,5532],{"class":135,"line":456},[133,5525,293],{"class":233},[133,5527,520],{"class":173},[133,5529,507],{"class":139},[133,5531,525],{"class":139},[133,5533,513],{"class":173},[10,5535,5536],{},"This will fix permissions for all files in the directory.",[10,5538,5539],{},"👉 Nginx must be able to read the files",[36,5541],{},[39,5543,4130],{"id":4129},[118,5545,5547,5548],{"id":5546},"forgot-to-run-collectstatic","🔴 Forgot to run ",[130,5549,218],{},[10,5551,1701],{},[123,5553,5554],{"className":224,"code":225,"language":226,"meta":128,"style":128},[130,5555,5556],{"__ignoreMap":128},[133,5557,5558,5560,5562],{"class":135,"line":136},[133,5559,127],{"class":233},[133,5561,236],{"class":173},[133,5563,239],{"class":173},[118,5565,5567,5568],{"id":5566},"wrong-static_root","🔴 Wrong ",[130,5569,212],{},[10,5571,5572],{},"Make sure:",[17,5574,5575,5578],{},[20,5576,5577],{},"Matches Nginx path",[20,5579,5580],{},"Is an absolute path",[118,5582,5584],{"id":5583},"nginx-misconfiguration","🔴 Nginx misconfiguration",[10,5586,5587],{},"Wrong:",[123,5589,5591],{"className":1461,"code":5590,"language":1463,"meta":128,"style":128},"root \u002Fvar\u002Fwww\u002Fmyproject\u002Fstatic;\n",[130,5592,5593],{"__ignoreMap":128},[133,5594,5595,5598],{"class":135,"line":136},[133,5596,5597],{"class":143},"root ",[133,5599,5600],{"class":169},"\u002Fvar\u002Fwww\u002Fmyproject\u002Fstatic;\n",[10,5602,5603],{},"Correct:",[123,5605,5607],{"className":1461,"code":5606,"language":1463,"meta":128,"style":128},"root \u002Fvar\u002Fwww\u002Fmyproject;\n",[130,5608,5609],{"__ignoreMap":128},[133,5610,5611,5613],{"class":135,"line":136},[133,5612,5597],{"class":143},[133,5614,2600],{"class":169},[118,5616,5618],{"id":5617},"debug-false-but-no-static-setup","🔴 DEBUG = False but no static setup",[10,5620,4531],{},[123,5622,5623],{"className":125,"code":126,"language":127,"meta":128,"style":128},[130,5624,5625],{"__ignoreMap":128},[133,5626,5627,5629,5631],{"class":135,"line":136},[133,5628,140],{"class":139},[133,5630,144],{"class":143},[133,5632,147],{"class":139},[10,5634,5635],{},"👉 Django stops serving static files",[118,5637,4851],{"id":4850},[10,5639,1701],{},[123,5641,5642],{"className":224,"code":2848,"language":226,"meta":128,"style":128},[130,5643,5644],{"__ignoreMap":128},[133,5645,5646,5648,5650,5652,5654],{"class":135,"line":136},[133,5647,293],{"class":233},[133,5649,504],{"class":173},[133,5651,507],{"class":139},[133,5653,510],{"class":173},[133,5655,513],{"class":173},[118,5657,5659],{"id":5658},"wrong-static_url","🔴 Wrong STATIC_URL",[10,5661,2692],{},[123,5663,5665],{"className":125,"code":5664,"language":127,"meta":128,"style":128},"STATIC_URL = '\u002Fstatic\u002F'\n",[130,5666,5667],{"__ignoreMap":128},[133,5668,5669,5671,5673],{"class":135,"line":136},[133,5670,1604],{"class":139},[133,5672,144],{"class":143},[133,5674,1609],{"class":173},[39,5676,1794],{"id":1793},[10,5678,4289],{},[123,5680,5681],{"className":224,"code":4092,"language":226,"meta":128,"style":128},[130,5682,5683],{"__ignoreMap":128},[133,5684,5685,5687,5689,5691],{"class":135,"line":136},[133,5686,293],{"class":233},[133,5688,596],{"class":173},[133,5690,599],{"class":139},[133,5692,602],{"class":173},[10,5694,3951],{},[17,5696,5697,5699],{},[20,5698,4927],{},[20,5700,4930],{},[10,5702,5703],{},"Check browser console:",[17,5705,5706,5709],{},[20,5707,5708],{},"Open DevTools → Network tab",[20,5710,5711,5712],{},"Look for:\n",[17,5713,5714,5716],{},[20,5715,4948],{},[20,5717,5718],{},"missing files",[36,5720],{},[39,5722,4338],{"id":4337},[17,5724,5726,5735,5744,5750,5755,5761],{"className":5725},[46],[20,5727,5729,5731,5732,5734],{"className":5728},[50],[52,5730],{"disabled":54,"type":55}," ",[130,5733,218],{}," was run",[20,5736,5738,5740,5741,5743],{"className":5737},[50],[52,5739],{"disabled":54,"type":55}," Files exist in ",[130,5742,5427],{}," folder",[20,5745,5747,5749],{"className":5746},[50],[52,5748],{"disabled":54,"type":55}," Nginx config is correct",[20,5751,5753,4371],{"className":5752},[50],[52,5754],{"disabled":54,"type":55},[20,5756,5758,5760],{"className":5757},[50],[52,5759],{"disabled":54,"type":55}," STATIC_ROOT is correct",[20,5762,5764,5766,5767],{"className":5763},[50],[52,5765],{"disabled":54,"type":55}," STATIC_URL = ",[130,5768,5427],{},[758,5770,5772],{"title":5771,"type":5027},"After static files are fixed, verify the rest of the stack",[10,5773,5774,5775,5777,5778,4397],{},"Compare your setup with the full ",[244,5776,1893],{"href":307}," and finish with the ",[244,5779,1898],{"href":1897},[36,5781],{},[39,5783,822],{"id":821},[17,5785,5786,5790,5794],{},[20,5787,5788],{},[244,5789,308],{"href":307},[20,5791,5792],{},[244,5793,788],{"href":787},[20,5795,5796],{},[244,5797,5798],{"href":265},"Fix Django media files not serving",[929,5800,5143],{},{"title":128,"searchDepth":466,"depth":466,"links":5802},[5803,5804,5805,5815,5825,5826,5827],{"id":3774,"depth":456,"text":3775},{"id":4527,"depth":456,"text":4528},{"id":3855,"depth":456,"text":3856,"children":5806},[5807,5809,5811,5812,5813,5814],{"id":5287,"depth":466,"text":5808},"1. Check STATIC_ROOT setting",{"id":5313,"depth":466,"text":5810},"2. Run collectstatic command",{"id":5369,"depth":466,"text":5370},{"id":5435,"depth":466,"text":5436},{"id":5469,"depth":466,"text":5470},{"id":4762,"depth":466,"text":4763},{"id":4129,"depth":456,"text":4130,"children":5816},[5817,5819,5821,5822,5823,5824],{"id":5546,"depth":466,"text":5818},"🔴 Forgot to run collectstatic",{"id":5566,"depth":466,"text":5820},"🔴 Wrong STATIC_ROOT",{"id":5583,"depth":466,"text":5584},{"id":5617,"depth":466,"text":5618},{"id":4850,"depth":466,"text":4851},{"id":5658,"depth":466,"text":5659},{"id":1793,"depth":456,"text":1794},{"id":4337,"depth":456,"text":4338},{"id":821,"depth":456,"text":822},"Static Assets","If your Django site loads but CSS is missing, JavaScript is broken, or the admin panel looks unstyled, then your static files are not being served correctly. This guide will help you fix it step-by-step.",{},"\u002Fdjango-static-files-not-loading-in-production","4",[307,1897,265],{"title":5190,"description":5829},"django-static-files-not-loading-in-production",[979,5837,980],"static-files","btyosFrywan0AfQSdxKK8V8gtKZBDIPAv7yYKnliKm0",{"id":5840,"title":5841,"body":5842,"category":6631,"description":6632,"extension":969,"meta":6633,"navigation":54,"path":6634,"priority":2033,"related":6635,"role":4446,"section":4447,"seo":6636,"stem":6637,"tags":6638,"__hash__":6640},"articles\u002Fgunicorn-socket-permission-denied-fix-guide.md","Fix Gunicorn Socket Permission Denied (Nginx + Django)",{"type":7,"value":5843,"toc":6600},[5844,5847,5863,5866,5872,5874,5876,5878,5925,5927,5929,5931,5935,5937,5950,5953,5958,5960,5962,5964,5968,5982,5984,5993,5996,6001,6003,6007,6021,6023,6032,6035,6040,6042,6046,6060,6063,6084,6087,6089,6093,6107,6109,6118,6121,6124,6126,6130,6145,6148,6150,6154,6166,6168,6170,6181,6184,6186,6188,6190,6194,6196,6212,6214,6230,6232,6236,6238,6255,6257,6281,6283,6287,6289,6304,6306,6310,6312,6328,6330,6334,6336,6357,6360,6369,6372,6374,6376,6378,6380,6394,6396,6405,6407,6411,6423,6425,6428,6440,6442,6444,6482,6484,6497,6499,6501,6516,6518,6520,6522,6526,6528,6535,6537,6541,6549,6551,6555,6557,6562,6564,6566,6569,6576,6579,6590,6592,6594,6597],[10,5845,5846],{},"If you're seeing errors like:",[17,5848,5849,5854,5860],{},[20,5850,5851],{},[130,5852,5853],{},"connect() to unix:\u002F...\u002Fgunicorn.sock failed (13: Permission denied)",[20,5855,5856,5857],{},"Nginx returns ",[353,5858,5859],{},"502 Bad Gateway",[20,5861,5862],{},"Gunicorn appears to be running, but requests fail",[10,5864,5865],{},"👉 Then you have a socket permission issue",[10,5867,5868,5869,4397],{},"This guide shows you exactly how to ",[353,5870,5871],{},"diagnose and fix it step-by-step",[36,5873],{},[39,5875,3775],{"id":3774},[10,5877,3778],{},[123,5879,5881],{"className":224,"code":5880,"language":226,"meta":128,"style":128},"sudo chown -R www-data:www-data \u002Fvar\u002Fwww\u002Fmyproject\nsudo chmod 755 \u002Fvar\u002Fwww\u002Fmyproject\nsudo systemctl restart gunicorn\nsudo systemctl restart nginx\n",[130,5882,5883,5895,5905,5915],{"__ignoreMap":128},[133,5884,5885,5887,5889,5891,5893],{"class":135,"line":136},[133,5886,293],{"class":233},[133,5888,504],{"class":173},[133,5890,507],{"class":139},[133,5892,510],{"class":173},[133,5894,513],{"class":173},[133,5896,5897,5899,5901,5903],{"class":135,"line":456},[133,5898,293],{"class":233},[133,5900,520],{"class":173},[133,5902,525],{"class":139},[133,5904,513],{"class":173},[133,5906,5907,5909,5911,5913],{"class":135,"line":466},[133,5908,293],{"class":233},[133,5910,296],{"class":173},[133,5912,709],{"class":173},[133,5914,302],{"class":173},[133,5916,5917,5919,5921,5923],{"class":135,"line":476},[133,5918,293],{"class":233},[133,5920,296],{"class":173},[133,5922,709],{"class":173},[133,5924,565],{"class":173},[10,5926,3816],{},[10,5928,4522],{},[36,5930],{},[39,5932,5934],{"id":5933},"what-this-error-means","🧠 What This Error Means",[10,5936,3831],{},[17,5938,5939,5944],{},[20,5940,5941,5943],{},[353,5942,1005],{}," creates a socket file",[20,5945,5946,5949],{},[353,5947,5948],{},"Nginx"," connects to it",[10,5951,5952],{},"Permission denied means:",[3762,5954,5955],{},[10,5956,5957],{},"Nginx does not have permission to access the socket file",[36,5959],{},[39,5961,3856],{"id":3855},[36,5963],{},[118,5965,5967],{"id":5966},"_1-locate-the-socket-file","1. Locate the socket file",[123,5969,5971],{"className":224,"code":5970,"language":226,"meta":128,"style":128},"ls -l \u002Fvar\u002Fwww\u002Fmyproject\u002F\n",[130,5972,5973],{"__ignoreMap":128},[133,5974,5975,5977,5980],{"class":135,"line":136},[133,5976,3981],{"class":233},[133,5978,5979],{"class":139}," -l",[133,5981,3984],{"class":173},[10,5983,3951],{},[123,5985,5987],{"className":615,"code":5986,"language":617,"meta":128,"style":128},"srwxrwx--- 1 www-data www-data gunicorn.sock\n",[130,5988,5989],{"__ignoreMap":128},[133,5990,5991],{"class":135,"line":136},[133,5992,5986],{},[10,5994,5995],{},"👉 If missing:",[17,5997,5998],{},[20,5999,6000],{},"Gunicorn is not creating the socket",[36,6002],{},[118,6004,6006],{"id":6005},"_2-check-ownership","2. Check ownership",[123,6008,6010],{"className":224,"code":6009,"language":226,"meta":128,"style":128},"ls -l \u002Fvar\u002Fwww\u002Fmyproject\u002Fgunicorn.sock\n",[130,6011,6012],{"__ignoreMap":128},[133,6013,6014,6016,6018],{"class":135,"line":136},[133,6015,3981],{"class":233},[133,6017,5979],{"class":139},[133,6019,6020],{"class":173}," \u002Fvar\u002Fwww\u002Fmyproject\u002Fgunicorn.sock\n",[10,6022,3880],{},[123,6024,6026],{"className":615,"code":6025,"language":617,"meta":128,"style":128},"www-data www-data\n",[130,6027,6028],{"__ignoreMap":128},[133,6029,6030],{"class":135,"line":136},[133,6031,6025],{},[10,6033,6034],{},"👉 If different:",[17,6036,6037],{},[20,6038,6039],{},"Nginx cannot access it",[36,6041],{},[118,6043,6045],{"id":6044},"_3-check-gunicorn-service-config","3. Check Gunicorn service config",[123,6047,6049],{"className":224,"code":6048,"language":226,"meta":128,"style":128},"sudo nano \u002Fetc\u002Fsystemd\u002Fsystem\u002Fgunicorn.service\n",[130,6050,6051],{"__ignoreMap":128},[133,6052,6053,6055,6057],{"class":135,"line":136},[133,6054,293],{"class":233},[133,6056,2542],{"class":173},[133,6058,6059],{"class":173}," \u002Fetc\u002Fsystemd\u002Fsystem\u002Fgunicorn.service\n",[10,6061,6062],{},"Ensure:",[123,6064,6066],{"className":2345,"code":6065,"language":2347,"meta":128,"style":128},"[Service]\nUser=www-data\nGroup=www-data\n",[130,6067,6068,6072,6078],{"__ignoreMap":128},[133,6069,6070],{"class":135,"line":136},[133,6071,2379],{"class":233},[133,6073,6074,6076],{"class":135,"line":456},[133,6075,2384],{"class":143},[133,6077,2387],{"class":169},[133,6079,6080,6082],{"class":135,"line":466},[133,6081,2392],{"class":143},[133,6083,2387],{"class":169},[10,6085,6086],{},"👉 This ensures Gunicorn creates the socket with the correct permissions",[36,6088],{},[118,6090,6092],{"id":6091},"_4-check-directory-permissions","4. Check directory permissions",[123,6094,6096],{"className":224,"code":6095,"language":226,"meta":128,"style":128},"ls -ld \u002Fvar\u002Fwww\u002Fmyproject\n",[130,6097,6098],{"__ignoreMap":128},[133,6099,6100,6102,6105],{"class":135,"line":136},[133,6101,3981],{"class":233},[133,6103,6104],{"class":139}," -ld",[133,6106,513],{"class":173},[10,6108,3880],{},[123,6110,6112],{"className":615,"code":6111,"language":617,"meta":128,"style":128},"drwxr-xr-x www-data www-data\n",[130,6113,6114],{"__ignoreMap":128},[133,6115,6116],{"class":135,"line":136},[133,6117,6111],{},[10,6119,6120],{},"👉 If too restrictive:",[10,6122,6123],{},"Nginx cannot traverse directory to access socket",[36,6125],{},[118,6127,6129],{"id":6128},"_5-restart-gunicorn","5. Restart Gunicorn",[123,6131,6133],{"className":224,"code":6132,"language":226,"meta":128,"style":128},"sudo systemctl restart gunicorn\n",[130,6134,6135],{"__ignoreMap":128},[133,6136,6137,6139,6141,6143],{"class":135,"line":136},[133,6138,293],{"class":233},[133,6140,296],{"class":173},[133,6142,709],{"class":173},[133,6144,302],{"class":173},[10,6146,6147],{},"Then check socket again.",[36,6149],{},[118,6151,6153],{"id":6152},"_6-check-nginx-config","6. Check Nginx config",[123,6155,6156],{"className":224,"code":2533,"language":226,"meta":128,"style":128},[130,6157,6158],{"__ignoreMap":128},[133,6159,6160,6162,6164],{"class":135,"line":136},[133,6161,293],{"class":233},[133,6163,2542],{"class":173},[133,6165,2545],{"class":173},[10,6167,4683],{},[10,6169,6062],{},[123,6171,6172],{"className":1461,"code":4179,"language":1463,"meta":128,"style":128},[130,6173,6174],{"__ignoreMap":128},[133,6175,6176,6179],{"class":135,"line":136},[133,6177,6178],{"class":143},"proxy_pass ",[133,6180,2631],{"class":169},[10,6182,6183],{},"👉 Path must match exactly",[36,6185],{},[39,6187,4130],{"id":4129},[36,6189],{},[118,6191,6193],{"id":6192},"wrong-file-ownership","🔴 Wrong file ownership",[10,6195,1701],{},[123,6197,6198],{"className":224,"code":2848,"language":226,"meta":128,"style":128},[130,6199,6200],{"__ignoreMap":128},[133,6201,6202,6204,6206,6208,6210],{"class":135,"line":136},[133,6203,293],{"class":233},[133,6205,504],{"class":173},[133,6207,507],{"class":139},[133,6209,510],{"class":173},[133,6211,513],{"class":173},[36,6213],{},[123,6215,6216],{"className":224,"code":2848,"language":226,"meta":128,"style":128},[130,6217,6218],{"__ignoreMap":128},[133,6219,6220,6222,6224,6226,6228],{"class":135,"line":136},[133,6221,293],{"class":233},[133,6223,504],{"class":173},[133,6225,507],{"class":139},[133,6227,510],{"class":173},[133,6229,513],{"class":173},[36,6231],{},[118,6233,6235],{"id":6234},"gunicorn-running-as-wrong-user","🔴 Gunicorn running as wrong user",[10,6237,1701],{},[123,6239,6241],{"className":2345,"code":6240,"language":2347,"meta":128,"style":128},"User=www-data\nGroup=www-data\n",[130,6242,6243,6249],{"__ignoreMap":128},[133,6244,6245,6247],{"class":135,"line":136},[133,6246,2384],{"class":143},[133,6248,2387],{"class":169},[133,6250,6251,6253],{"class":135,"line":456},[133,6252,2392],{"class":143},[133,6254,2387],{"class":169},[10,6256,4745],{},[123,6258,6260],{"className":224,"code":6259,"language":226,"meta":128,"style":128},"sudo systemctl daemon-reexec\nsudo systemctl restart gunicorn\n",[130,6261,6262,6271],{"__ignoreMap":128},[133,6263,6264,6266,6268],{"class":135,"line":136},[133,6265,293],{"class":233},[133,6267,296],{"class":173},[133,6269,6270],{"class":173}," daemon-reexec\n",[133,6272,6273,6275,6277,6279],{"class":135,"line":456},[133,6274,293],{"class":233},[133,6276,296],{"class":173},[133,6278,709],{"class":173},[133,6280,302],{"class":173},[36,6282],{},[118,6284,6286],{"id":6285},"directory-permissions-too-strict","🔴 Directory permissions too strict",[10,6288,1701],{},[123,6290,6292],{"className":224,"code":6291,"language":226,"meta":128,"style":128},"sudo chmod 755 \u002Fvar\u002Fwww\u002Fmyproject\n",[130,6293,6294],{"__ignoreMap":128},[133,6295,6296,6298,6300,6302],{"class":135,"line":136},[133,6297,293],{"class":233},[133,6299,520],{"class":173},[133,6301,525],{"class":139},[133,6303,513],{"class":173},[36,6305],{},[118,6307,6309],{"id":6308},"socket-permissions-incorrect","🔴 Socket permissions incorrect",[10,6311,1701],{},[123,6313,6315],{"className":224,"code":6314,"language":226,"meta":128,"style":128},"sudo chmod 660 \u002Fvar\u002Fwww\u002Fmyproject\u002Fgunicorn.sock\n",[130,6316,6317],{"__ignoreMap":128},[133,6318,6319,6321,6323,6326],{"class":135,"line":136},[133,6320,293],{"class":233},[133,6322,520],{"class":173},[133,6324,6325],{"class":139}," 660",[133,6327,6020],{"class":173},[36,6329],{},[118,6331,6333],{"id":6332},"nginx-running-as-different-user","🔴 Nginx running as different user",[10,6335,365],{},[123,6337,6339],{"className":224,"code":6338,"language":226,"meta":128,"style":128},"ps aux | grep nginx\n",[130,6340,6341],{"__ignoreMap":128},[133,6342,6343,6346,6349,6352,6355],{"class":135,"line":136},[133,6344,6345],{"class":233},"ps",[133,6347,6348],{"class":173}," aux",[133,6350,6351],{"class":143}," |",[133,6353,6354],{"class":233}," grep",[133,6356,565],{"class":173},[10,6358,6359],{},"Usually:",[123,6361,6363],{"className":615,"code":6362,"language":617,"meta":128,"style":128},"www-data\n",[130,6364,6365],{"__ignoreMap":128},[133,6366,6367],{"class":135,"line":136},[133,6368,6362],{},[10,6370,6371],{},"👉 Must match Gunicorn group",[36,6373],{},[39,6375,1794],{"id":1793},[36,6377],{},[118,6379,4904],{"id":4903},[123,6381,6382],{"className":224,"code":4092,"language":226,"meta":128,"style":128},[130,6383,6384],{"__ignoreMap":128},[133,6385,6386,6388,6390,6392],{"class":135,"line":136},[133,6387,293],{"class":233},[133,6389,596],{"class":173},[133,6391,599],{"class":139},[133,6393,602],{"class":173},[10,6395,3951],{},[17,6397,6398,6402],{},[20,6399,6400],{},[130,6401,4930],{},[20,6403,6404],{},"socket errors",[36,6406],{},[118,6408,6410],{"id":6409},"check-gunicorn-logs","Check Gunicorn logs",[123,6412,6413],{"className":224,"code":4220,"language":226,"meta":128,"style":128},[130,6414,6415],{"__ignoreMap":128},[133,6416,6417,6419,6421],{"class":135,"line":136},[133,6418,584],{"class":233},[133,6420,587],{"class":139},[133,6422,302],{"class":173},[36,6424],{},[10,6426,6427],{},"Check socket permissions directly",[123,6429,6431],{"className":224,"code":6430,"language":226,"meta":128,"style":128},"stat \u002Fvar\u002Fwww\u002Fmyproject\u002Fgunicorn.sock\n",[130,6432,6433],{"__ignoreMap":128},[133,6434,6435,6438],{"class":135,"line":136},[133,6436,6437],{"class":139},"stat",[133,6439,6020],{"class":173},[36,6441],{},[39,6443,4338],{"id":4337},[17,6445,6447,6452,6458,6464,6470,6476],{"className":6446},[46],[20,6448,6450,4359],{"className":6449},[50],[52,6451],{"disabled":54,"type":55},[20,6453,6455,6457],{"className":6454},[50],[52,6456],{"disabled":54,"type":55}," Owned by www-data",[20,6459,6461,6463],{"className":6460},[50],[52,6462],{"disabled":54,"type":55}," Gunicorn runs as www-data",[20,6465,6467,6469],{"className":6466},[50],[52,6468],{"disabled":54,"type":55}," Directory permissions allow access",[20,6471,6473,6475],{"className":6472},[50],[52,6474],{"disabled":54,"type":55}," Nginx uses correct socket path",[20,6477,6479,6481],{"className":6478},[50],[52,6480],{"disabled":54,"type":55}," Services restarted",[36,6483],{},[758,6485,6487],{"title":6486,"type":4383},"After fixing permissions, confirm the full Nginx ↔ Gunicorn chain",[10,6488,6489,6490,6493,6494,4397],{},"If requests still fail, walk through the focused ",[244,6491,6492],{"href":793},"connection refused guide"," and compare your service layout with the main ",[244,6495,6496],{"href":307},"deploy tutorial",[36,6498],{},[39,6500,822],{"id":821},[17,6502,6503,6507,6512],{},[20,6504,6505],{},[244,6506,788],{"href":787},[20,6508,6509],{},[244,6510,6511],{"href":793},"Nginx not connecting to Gunicorn",[20,6513,6514],{},[244,6515,308],{"href":307},[36,6517],{},[39,6519,850],{"id":849},[36,6521],{},[118,6523,6525],{"id":6524},"why-does-this-error-happen","Why does this error happen?",[10,6527,5103],{},[17,6529,6530,6533],{},[20,6531,6532],{},"Gunicorn creates the socket",[20,6534,6039],{},[36,6536],{},[118,6538,6540],{"id":6539},"should-i-use-sockets-or-ports","Should I use sockets or ports?",[17,6542,6543,6546],{},[20,6544,6545],{},"Sockets → faster, more efficient",[20,6547,6548],{},"Ports → easier debugging",[36,6550],{},[118,6552,6554],{"id":6553},"why-does-restarting-fix-it-sometimes","Why does restarting fix it sometimes?",[10,6556,5103],{},[17,6558,6559],{},[20,6560,6561],{},"Socket gets recreated with correct permissions",[36,6563],{},[39,6565,905],{"id":904},[10,6567,6568],{},"“Permission denied” means:",[3762,6570,6571],{},[10,6572,6573],{},[353,6574,6575],{},"Nginx cannot access Gunicorn’s socket",[10,6577,6578],{},"Fix it by ensuring:",[17,6580,6581,6584,6587],{},[20,6582,6583],{},"Correct ownership",[20,6585,6586],{},"Correct permissions",[20,6588,6589],{},"Matching configuration",[36,6591],{},[10,6593,924],{},[10,6595,6596],{},"A repeatable, tested setup will prevent this issue entirely.",[929,6598,6599],{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}",{"title":128,"searchDepth":466,"depth":466,"links":6601},[6602,6603,6604,6612,6619,6623,6624,6625,6630],{"id":3774,"depth":456,"text":3775},{"id":5933,"depth":456,"text":5934},{"id":3855,"depth":456,"text":3856,"children":6605},[6606,6607,6608,6609,6610,6611],{"id":5966,"depth":466,"text":5967},{"id":6005,"depth":466,"text":6006},{"id":6044,"depth":466,"text":6045},{"id":6091,"depth":466,"text":6092},{"id":6128,"depth":466,"text":6129},{"id":6152,"depth":466,"text":6153},{"id":4129,"depth":456,"text":4130,"children":6613},[6614,6615,6616,6617,6618],{"id":6192,"depth":466,"text":6193},{"id":6234,"depth":466,"text":6235},{"id":6285,"depth":466,"text":6286},{"id":6308,"depth":466,"text":6309},{"id":6332,"depth":466,"text":6333},{"id":1793,"depth":456,"text":1794,"children":6620},[6621,6622],{"id":4903,"depth":466,"text":4904},{"id":6409,"depth":466,"text":6410},{"id":4337,"depth":456,"text":4338},{"id":821,"depth":456,"text":822},{"id":849,"depth":456,"text":850,"children":6626},[6627,6628,6629],{"id":6524,"depth":466,"text":6525},{"id":6539,"depth":466,"text":6540},{"id":6553,"depth":466,"text":6554},{"id":904,"depth":456,"text":905},"Permissions","Learn how to resolve 'Permission Denied' errors when Nginx tries to access Gunicorn's socket file. This guide covers common causes and step-by-step fixes to ensure smooth communication between Nginx and Gunicorn in your Django deployment.",{},"\u002Fgunicorn-socket-permission-denied-fix-guide",[787,793,307],{"title":5841,"description":6632},"gunicorn-socket-permission-denied-fix-guide",[2302,1463,6639],"linux","KFTdh9yIWanls4_deDCuhMOJX_TL16WKHqg-HIMPayw",{"id":6642,"title":6643,"body":6644,"category":4441,"description":7400,"extension":969,"meta":7401,"navigation":54,"path":7402,"priority":7403,"related":7404,"role":4446,"section":4447,"seo":7405,"stem":7406,"tags":7407,"__hash__":7409},"articles\u002Ffix-nginx-not-connecting-to-gunicorn-connection-refused.md","Fix Nginx Not Connecting to Gunicorn (Connection Refused)",{"type":7,"value":6645,"toc":7369},[6646,6648,6661,6664,6667,6669,6671,6673,6697,6699,6701,6703,6707,6710,6715,6718,6729,6731,6733,6736,6738,6752,6754,6761,6763,6765,6779,6781,6799,6801,6810,6814,6817,6837,6839,6848,6851,6861,6863,6871,6873,6875,6887,6890,6902,6905,6915,6918,6922,6932,6935,6940,6942,6947,6949,6963,6966,6970,6984,6986,6995,6997,6999,7001,7005,7007,7031,7033,7037,7040,7048,7051,7053,7057,7059,7071,7074,7081,7083,7087,7089,7097,7099,7103,7105,7132,7134,7137,7139,7156,7158,7162,7174,7177,7194,7197,7221,7223,7225,7261,7263,7276,7278,7280,7294,7296,7298,7302,7311,7315,7323,7327,7329,7337,7339,7341,7344,7349,7352,7360,7362,7364,7367],[10,6647,5846],{},[17,6649,6650,6655,6658],{},[20,6651,6652],{},[130,6653,6654],{},"connect() failed (111: Connection refused)",[20,6656,6657],{},"Nginx returns 502 Bad Gateway",[20,6659,6660],{},"Your Django app is not reachable",[10,6662,6663],{},"👉 Then Nginx cannot connect to Gunicorn.",[10,6665,6666],{},"This guide will help you identify and fix the issue step-by-step.",[36,6668],{},[39,6670,3775],{"id":3774},[10,6672,3778],{},[123,6674,6675],{"className":224,"code":2802,"language":226,"meta":128,"style":128},[130,6676,6677,6687],{"__ignoreMap":128},[133,6678,6679,6681,6683,6685],{"class":135,"line":136},[133,6680,293],{"class":233},[133,6682,296],{"class":173},[133,6684,709],{"class":173},[133,6686,302],{"class":173},[133,6688,6689,6691,6693,6695],{"class":135,"line":456},[133,6690,293],{"class":233},[133,6692,296],{"class":173},[133,6694,709],{"class":173},[133,6696,565],{"class":173},[10,6698,3816],{},[10,6700,4522],{},[36,6702],{},[39,6704,6706],{"id":6705},"what-connection-refused-means","🧠 What “Connection Refused” Means",[10,6708,6709],{},"This error means:",[3762,6711,6712],{},[10,6713,6714],{},"Nginx tried to connect to Gunicorn, but nothing was listening",[10,6716,6717],{},"Common reasons:",[17,6719,6720,6723,6726],{},[20,6721,6722],{},"Gunicorn is not running",[20,6724,6725],{},"Wrong port\u002Fsocket",[20,6727,6728],{},"Misconfiguration",[36,6730],{},[39,6732,3856],{"id":3855},[10,6734,6735],{},"Follow these steps carefully.",[118,6737,3863],{"id":3862},[123,6739,6740],{"className":224,"code":2481,"language":226,"meta":128,"style":128},[130,6741,6742],{"__ignoreMap":128},[133,6743,6744,6746,6748,6750],{"class":135,"line":136},[133,6745,293],{"class":233},[133,6747,296],{"class":173},[133,6749,2492],{"class":173},[133,6751,302],{"class":173},[10,6753,3880],{},[17,6755,6756],{},[20,6757,6758],{},[130,6759,6760],{},"active (running)",[10,6762,3898],{},[10,6764,3901],{},[123,6766,6767],{"className":224,"code":3904,"language":226,"meta":128,"style":128},[130,6768,6769],{"__ignoreMap":128},[133,6770,6771,6773,6775,6777],{"class":135,"line":136},[133,6772,293],{"class":233},[133,6774,296],{"class":173},[133,6776,2461],{"class":173},[133,6778,302],{"class":173},[118,6780,3925],{"id":3924},[123,6782,6783],{"className":224,"code":3928,"language":226,"meta":128,"style":128},[130,6784,6785],{"__ignoreMap":128},[133,6786,6787,6789,6791,6793,6795,6797],{"class":135,"line":136},[133,6788,584],{"class":233},[133,6790,587],{"class":139},[133,6792,3939],{"class":173},[133,6794,3942],{"class":139},[133,6796,3945],{"class":139},[133,6798,3948],{"class":139},[10,6800,3951],{},[17,6802,6803,6805,6808],{},[20,6804,3956],{},[20,6806,6807],{},"Import failures",[20,6809,4238],{},[118,6811,6813],{"id":6812},"_3-check-what-gunicorn-is-listening-on","3. Check what Gunicorn is listening on",[10,6815,6816],{},"If using TCP:",[123,6818,6820],{"className":224,"code":6819,"language":226,"meta":128,"style":128},"ss -tulnp | grep 8000\n",[130,6821,6822],{"__ignoreMap":128},[133,6823,6824,6827,6830,6832,6834],{"class":135,"line":136},[133,6825,6826],{"class":233},"ss",[133,6828,6829],{"class":139}," -tulnp",[133,6831,6351],{"class":143},[133,6833,6354],{"class":233},[133,6835,6836],{"class":139}," 8000\n",[10,6838,3880],{},[123,6840,6842],{"className":615,"code":6841,"language":617,"meta":128,"style":128},"LISTEN 0 128 127.0.0.1:8000\n",[130,6843,6844],{"__ignoreMap":128},[133,6845,6846],{"class":135,"line":136},[133,6847,6841],{},[10,6849,6850],{},"If using socket:",[123,6852,6853],{"className":224,"code":3974,"language":226,"meta":128,"style":128},[130,6854,6855],{"__ignoreMap":128},[133,6856,6857,6859],{"class":135,"line":136},[133,6858,3981],{"class":233},[133,6860,3984],{"class":173},[10,6862,3951],{},[123,6864,6865],{"className":615,"code":3990,"language":617,"meta":128,"style":128},[130,6866,6867],{"__ignoreMap":128},[133,6868,6869],{"class":135,"line":136},[133,6870,3990],{},[118,6872,4665],{"id":4664},[10,6874,1674],{},[123,6876,6877],{"className":224,"code":2533,"language":226,"meta":128,"style":128},[130,6878,6879],{"__ignoreMap":128},[133,6880,6881,6883,6885],{"class":135,"line":136},[133,6882,293],{"class":233},[133,6884,2542],{"class":173},[133,6886,2545],{"class":173},[10,6888,6889],{},"For TCP setup:",[123,6891,6893],{"className":1461,"code":6892,"language":1463,"meta":128,"style":128},"proxy_pass http:\u002F\u002F127.0.0.1:8000;\n",[130,6894,6895],{"__ignoreMap":128},[133,6896,6897,6899],{"class":135,"line":136},[133,6898,6178],{"class":143},[133,6900,6901],{"class":169},"http:\u002F\u002F127.0.0.1:8000;\n",[10,6903,6904],{},"For socket setup:",[123,6906,6907],{"className":1461,"code":4179,"language":1463,"meta":128,"style":128},[130,6908,6909],{"__ignoreMap":128},[133,6910,6911,6913],{"class":135,"line":136},[133,6912,6178],{"class":143},[133,6914,2631],{"class":169},[10,6916,6917],{},"👉 These must match Gunicorn exactly",[118,6919,6921],{"id":6920},"_5-test-gunicorn-directly","5. Test Gunicorn directly",[123,6923,6924],{"className":224,"code":4013,"language":226,"meta":128,"style":128},[130,6925,6926],{"__ignoreMap":128},[133,6927,6928,6930],{"class":135,"line":136},[133,6929,4020],{"class":233},[133,6931,4023],{"class":173},[10,6933,6934],{},"If fails:",[17,6936,6937],{},[20,6938,6939],{},"Gunicorn is not running correctly",[10,6941,4656],{},[17,6943,6944],{},[20,6945,6946],{},"Problem is Nginx configuration",[118,6948,4072],{"id":4071},[123,6950,6951],{"className":224,"code":4075,"language":226,"meta":128,"style":128},[130,6952,6953],{"__ignoreMap":128},[133,6954,6955,6957,6959,6961],{"class":135,"line":136},[133,6956,293],{"class":233},[133,6958,296],{"class":173},[133,6960,709],{"class":173},[133,6962,565],{"class":173},[10,6964,6965],{},"Then check your site again.",[118,6967,6969],{"id":6968},"_7-check-nginx-logs","7. Check Nginx logs",[123,6971,6972],{"className":224,"code":4092,"language":226,"meta":128,"style":128},[130,6973,6974],{"__ignoreMap":128},[133,6975,6976,6978,6980,6982],{"class":135,"line":136},[133,6977,293],{"class":233},[133,6979,596],{"class":173},[133,6981,599],{"class":139},[133,6983,602],{"class":173},[10,6985,3951],{},[17,6987,6988,6990,6993],{},[20,6989,4389],{},[20,6991,6992],{},"no such file",[20,6994,4930],{},[36,6996],{},[39,6998,4130],{"id":4129},[36,7000],{},[118,7002,7004],{"id":7003},"gunicorn-not-running","🔴 Gunicorn not running",[10,7006,1701],{},[123,7008,7009],{"className":224,"code":2450,"language":226,"meta":128,"style":128},[130,7010,7011,7021],{"__ignoreMap":128},[133,7012,7013,7015,7017,7019],{"class":135,"line":136},[133,7014,293],{"class":233},[133,7016,296],{"class":173},[133,7018,2461],{"class":173},[133,7020,302],{"class":173},[133,7022,7023,7025,7027,7029],{"class":135,"line":456},[133,7024,293],{"class":233},[133,7026,296],{"class":173},[133,7028,299],{"class":173},[133,7030,302],{"class":173},[36,7032],{},[118,7034,7036],{"id":7035},"wrong-port-or-socket","🔴 Wrong port or socket",[10,7038,7039],{},"Mismatch between:",[17,7041,7042,7045],{},[20,7043,7044],{},"Gunicorn bind",[20,7046,7047],{},"Nginx proxy_pass",[10,7049,7050],{},"Fix by aligning both",[36,7052],{},[118,7054,7056],{"id":7055},"gunicorn-crashed","🔴 Gunicorn crashed",[10,7058,365],{},[123,7060,7061],{"className":224,"code":4220,"language":226,"meta":128,"style":128},[130,7062,7063],{"__ignoreMap":128},[133,7064,7065,7067,7069],{"class":135,"line":136},[133,7066,584],{"class":233},[133,7068,587],{"class":139},[133,7070,302],{"class":173},[10,7072,7073],{},"Common issues:",[17,7075,7076,7079],{},[20,7077,7078],{},"Syntax errors",[20,7080,3962],{},[36,7082],{},[118,7084,7086],{"id":7085},"socket-file-missing","🔴 Socket file missing",[10,7088,1701],{},[17,7090,7091,7094],{},[20,7092,7093],{},"Ensure Gunicorn creates socket",[20,7095,7096],{},"Check working directory",[36,7098],{},[118,7100,7102],{"id":7101},"permission-denied-on-socket","🔴 Permission denied on socket",[10,7104,1701],{},[123,7106,7108],{"className":224,"code":7107,"language":226,"meta":128,"style":128},"sudo chown -R www-data:www-data \u002Fvar\u002Fwww\u002Fmyproject\nsudo chmod 755 \u002Fvar\u002Fwww\u002Fmyproject\n",[130,7109,7110,7122],{"__ignoreMap":128},[133,7111,7112,7114,7116,7118,7120],{"class":135,"line":136},[133,7113,293],{"class":233},[133,7115,504],{"class":173},[133,7117,507],{"class":139},[133,7119,510],{"class":173},[133,7121,513],{"class":173},[133,7123,7124,7126,7128,7130],{"class":135,"line":456},[133,7125,293],{"class":233},[133,7127,520],{"class":173},[133,7129,525],{"class":139},[133,7131,513],{"class":173},[36,7133],{},[10,7135,7136],{},"🔴 Firewall blocking connection",[10,7138,6816],{},[123,7140,7142],{"className":224,"code":7141,"language":226,"meta":128,"style":128},"sudo ufw allow 8000\n",[130,7143,7144],{"__ignoreMap":128},[133,7145,7146,7148,7151,7154],{"class":135,"line":136},[133,7147,293],{"class":233},[133,7149,7150],{"class":173}," ufw",[133,7152,7153],{"class":173}," allow",[133,7155,6836],{"class":139},[39,7157,1794],{"id":1793},[118,7159,7161],{"id":7160},"check-listening-ports","Check listening ports",[123,7163,7165],{"className":224,"code":7164,"language":226,"meta":128,"style":128},"ss -tulnp\n",[130,7166,7167],{"__ignoreMap":128},[133,7168,7169,7171],{"class":135,"line":136},[133,7170,6826],{"class":233},[133,7172,7173],{"class":139}," -tulnp\n",[10,7175,7176],{},"Check Gunicorn process",[123,7178,7180],{"className":224,"code":7179,"language":226,"meta":128,"style":128},"ps aux | grep gunicorn\n",[130,7181,7182],{"__ignoreMap":128},[133,7183,7184,7186,7188,7190,7192],{"class":135,"line":136},[133,7185,6345],{"class":233},[133,7187,6348],{"class":173},[133,7189,6351],{"class":143},[133,7191,6354],{"class":233},[133,7193,302],{"class":173},[10,7195,7196],{},"Restart everything cleanly",[123,7198,7199],{"className":224,"code":2802,"language":226,"meta":128,"style":128},[130,7200,7201,7211],{"__ignoreMap":128},[133,7202,7203,7205,7207,7209],{"class":135,"line":136},[133,7204,293],{"class":233},[133,7206,296],{"class":173},[133,7208,709],{"class":173},[133,7210,302],{"class":173},[133,7212,7213,7215,7217,7219],{"class":135,"line":456},[133,7214,293],{"class":233},[133,7216,296],{"class":173},[133,7218,709],{"class":173},[133,7220,565],{"class":173},[36,7222],{},[39,7224,4338],{"id":4337},[17,7226,7228,7233,7239,7245,7251,7256],{"className":7227},[46],[20,7229,7231,4347],{"className":7230},[50],[52,7232],{"disabled":54,"type":55},[20,7234,7236,7238],{"className":7235},[50],[52,7237],{"disabled":54,"type":55}," Correct port\u002Fsocket configured",[20,7240,7242,7244],{"className":7241},[50],[52,7243],{"disabled":54,"type":55}," Nginx config matches Gunicorn",[20,7246,7248,7250],{"className":7247},[50],[52,7249],{"disabled":54,"type":55}," No errors in logs",[20,7252,7254,4371],{"className":7253},[50],[52,7255],{"disabled":54,"type":55},[20,7257,7259,5021],{"className":7258},[50],[52,7260],{"disabled":54,"type":55},[36,7262],{},[758,7264,7266],{"title":7265,"type":4383},"If Nginx can connect again, validate the rest of the path",[10,7267,7268,7269,7271,7272,7275],{},"Compare your socket setup with the full ",[244,7270,4396],{"href":307}," and check the dedicated ",[244,7273,7274],{"href":787},"502 Bad Gateway guide"," if the error changes.",[36,7277],{},[39,7279,822],{"id":821},[17,7281,7282,7286,7290],{},[20,7283,7284],{},[244,7285,788],{"href":787},[20,7287,7288],{},[244,7289,308],{"href":307},[20,7291,7292],{},[244,7293,800],{"href":799},[36,7295],{},[39,7297,850],{"id":849},[118,7299,7301],{"id":7300},"what-causes-connection-refused","What causes “connection refused”?",[17,7303,7304,7307,7309],{},[20,7305,7306],{},"Gunicorn not running",[20,7308,6725],{},[20,7310,6728],{},[118,7312,7314],{"id":7313},"should-i-use-socket-or-tcp","Should I use socket or TCP?",[17,7316,7317,7320],{},[20,7318,7319],{},"Socket → better performance",[20,7321,7322],{},"TCP → easier debugging",[118,7324,7326],{"id":7325},"why-does-it-work-locally-but-not-in-production","Why does it work locally but not in production?",[10,7328,5103],{},[17,7330,7331,7334],{},[20,7332,7333],{},"Production uses Nginx + Gunicorn",[20,7335,7336],{},"Local uses Django dev server",[36,7338],{},[39,7340,905],{"id":904},[10,7342,7343],{},"“Connection refused” means:",[3762,7345,7346],{},[10,7347,7348],{},"Nginx cannot reach Gunicorn",[10,7350,7351],{},"Fix it by checking:",[17,7353,7354,7357],{},[20,7355,7356],{},"Gunicorn status",[20,7358,7359],{},"Ports\u002Fsockets\n*Configuration alignment",[36,7361],{},[10,7363,924],{},[10,7365,7366],{},"A repeatable, tested setup saves hours of debugging.",[929,7368,6599],{},{"title":128,"searchDepth":466,"depth":466,"links":7370},[7371,7372,7373,7382,7389,7392,7393,7394,7399],{"id":3774,"depth":456,"text":3775},{"id":6705,"depth":456,"text":6706},{"id":3855,"depth":456,"text":3856,"children":7374},[7375,7376,7377,7378,7379,7380,7381],{"id":3862,"depth":466,"text":3863},{"id":3924,"depth":466,"text":3925},{"id":6812,"depth":466,"text":6813},{"id":4664,"depth":466,"text":4665},{"id":6920,"depth":466,"text":6921},{"id":4071,"depth":466,"text":4072},{"id":6968,"depth":466,"text":6969},{"id":4129,"depth":456,"text":4130,"children":7383},[7384,7385,7386,7387,7388],{"id":7003,"depth":466,"text":7004},{"id":7035,"depth":466,"text":7036},{"id":7055,"depth":466,"text":7056},{"id":7085,"depth":466,"text":7086},{"id":7101,"depth":466,"text":7102},{"id":1793,"depth":456,"text":1794,"children":7390},[7391],{"id":7160,"depth":466,"text":7161},{"id":4337,"depth":456,"text":4338},{"id":821,"depth":456,"text":822},{"id":849,"depth":456,"text":850,"children":7395},[7396,7397,7398],{"id":7300,"depth":466,"text":7301},{"id":7313,"depth":466,"text":7314},{"id":7325,"depth":466,"text":7326},{"id":904,"depth":456,"text":905},"Learn how to troubleshoot and fix the 'Connection Refused' error when Nginx fails to connect to Gunicorn. This guide covers common causes and solutions to get your web application running smoothly.",{},"\u002Ffix-nginx-not-connecting-to-gunicorn-connection-refused","2",[787,799,307],{"title":6643,"description":7400},"fix-nginx-not-connecting-to-gunicorn-connection-refused",[1463,2302,7408],"connection-refused","nTIfw0KHMoiHg6dQ_AQfX4jOvPoqoTWQUq2EwtuWTlc",{"id":7411,"title":7412,"body":7413,"category":8040,"description":8041,"extension":969,"meta":8042,"navigation":54,"path":8043,"priority":7403,"related":8044,"role":8045,"section":2036,"seo":8046,"stem":8047,"tags":8048,"__hash__":8051},"articles\u002Fhow-to-set-up-https-for-django-nginx-lets-encrypt.md","How to Set Up HTTPS for Django (Nginx + Let’s Encrypt)",{"type":7,"value":7414,"toc":8009},[7415,7418,7429,7436,7448,7450,7454,7456,7489,7492,7495,7506,7508,7512,7523,7527,7531,7534,7557,7559,7563,7580,7582,7586,7598,7601,7612,7615,7617,7621,7623,7632,7635,7638,7642,7647,7677,7680,7682,7686,7689,7692,7709,7712,7714,7718,7720,7724,7726,7734,7736,7738,7750,7752,7756,7758,7774,7776,7780,7783,7791,7793,7795,7797,7801,7818,7820,7822,7836,7838,7842,7857,7859,7863,7902,7904,7917,7919,7921,7936,7938,7940,7944,7947,7950,7958,7960,7964,7967,7970,7972,7976,7978,7981,7983,7985,7988,7999,8001,8003,8006],[10,7416,7417],{},"If your Django site is running on HTTP, it is:",[17,7419,7420,7423,7426],{},[20,7421,7422],{},"❌ Not secure",[20,7424,7425],{},"❌ Flagged by browsers",[20,7427,7428],{},"❌ Vulnerable to attacks",[10,7430,7431,7432,7435],{},"This guide shows you how to ",[353,7433,7434],{},"secure your Django app with HTTPS"," using:",[17,7437,7438,7440,7445],{},[20,7439,5948],{},[20,7441,7442],{},[244,7443,400],{"href":397,"rel":7444},[399],[20,7446,7447],{},"Certbot",[36,7449],{},[39,7451,7453],{"id":7452},"quick-setup-fastest-method","⚡ Quick Setup (Fastest Method)",[10,7455,3778],{},[123,7457,7459],{"className":224,"code":7458,"language":226,"meta":128,"style":128},"sudo apt update\nsudo apt install certbot python3-certbot-nginx\nsudo certbot --nginx\n",[130,7460,7461,7469,7481],{"__ignoreMap":128},[133,7462,7463,7465,7467],{"class":135,"line":136},[133,7464,293],{"class":233},[133,7466,2512],{"class":173},[133,7468,2515],{"class":173},[133,7470,7471,7473,7475,7477,7479],{"class":135,"line":456},[133,7472,293],{"class":233},[133,7474,2512],{"class":173},[133,7476,677],{"class":173},[133,7478,413],{"class":173},[133,7480,2918],{"class":173},[133,7482,7483,7485,7487],{"class":135,"line":466},[133,7484,293],{"class":233},[133,7486,413],{"class":173},[133,7488,416],{"class":139},[10,7490,7491],{},"Follow the prompts.",[10,7493,7494],{},"👉 This will:",[17,7496,7497,7500,7503],{},[20,7498,7499],{},"Obtain SSL certificate",[20,7501,7502],{},"Configure Nginx automatically",[20,7504,7505],{},"Enable HTTPS",[36,7507],{},[39,7509,7511],{"id":7510},"what-this-does","🧠 What This Does",[17,7513,7514,7517,7520],{},[20,7515,7516],{},"Encrypts traffic between users and your server",[20,7518,7519],{},"Prevents interception and tampering",[20,7521,7522],{},"Enables modern browser features",[39,7524,7526],{"id":7525},"step-by-step-setup","🧪 Step-by-Step Setup",[118,7528,7530],{"id":7529},"_1-ensure-nginx-is-working","1. Ensure Nginx is working",[10,7532,7533],{},"Test:",[123,7535,7537],{"className":224,"code":7536,"language":226,"meta":128,"style":128},"sudo nginx -t\nsudo systemctl status nginx\n",[130,7538,7539,7547],{"__ignoreMap":128},[133,7540,7541,7543,7545],{"class":135,"line":136},[133,7542,293],{"class":233},[133,7544,337],{"class":173},[133,7546,340],{"class":139},[133,7548,7549,7551,7553,7555],{"class":135,"line":456},[133,7550,293],{"class":233},[133,7552,296],{"class":173},[133,7554,2492],{"class":173},[133,7556,565],{"class":173},[36,7558],{},[118,7560,7562],{"id":7561},"_2-install-certbot","2. Install Certbot",[123,7564,7566],{"className":224,"code":7565,"language":226,"meta":128,"style":128},"sudo apt install certbot python3-certbot-nginx\n",[130,7567,7568],{"__ignoreMap":128},[133,7569,7570,7572,7574,7576,7578],{"class":135,"line":136},[133,7571,293],{"class":233},[133,7573,2512],{"class":173},[133,7575,677],{"class":173},[133,7577,413],{"class":173},[133,7579,2918],{"class":173},[36,7581],{},[118,7583,7585],{"id":7584},"_3-run-certbot","3. Run Certbot",[123,7587,7588],{"className":224,"code":404,"language":226,"meta":128,"style":128},[130,7589,7590],{"__ignoreMap":128},[133,7591,7592,7594,7596],{"class":135,"line":136},[133,7593,293],{"class":233},[133,7595,413],{"class":173},[133,7597,416],{"class":139},[10,7599,7600],{},"You will be prompted for:",[17,7602,7603,7606,7609],{},[20,7604,7605],{},"Email address",[20,7607,7608],{},"Domain name",[20,7610,7611],{},"Redirect HTTP → HTTPS",[10,7613,7614],{},"👉 Choose redirect for best practice",[36,7616],{},[118,7618,7620],{"id":7619},"_4-verify-https","4. Verify HTTPS",[10,7622,1674],{},[123,7624,7626],{"className":615,"code":7625,"language":617,"meta":128,"style":128},"https:\u002F\u002Fyour-domain.com\n",[130,7627,7628],{"__ignoreMap":128},[133,7629,7630],{"class":135,"line":136},[133,7631,7625],{},[10,7633,7634],{},"👉 You should see:",[10,7636,7637],{},"Secure lock icon in browser",[39,7639,7641],{"id":7640},"configure-django-for-https","🔐 Configure Django for HTTPS",[10,7643,7644,7645,438],{},"Update ",[130,7646,437],{},[123,7648,7650],{"className":125,"code":7649,"language":127,"meta":128,"style":128},"SECURE_SSL_REDIRECT = True\nCSRF_COOKIE_SECURE = True\nSESSION_COOKIE_SECURE = True\n",[130,7651,7652,7661,7669],{"__ignoreMap":128},[133,7653,7654,7657,7659],{"class":135,"line":136},[133,7655,7656],{"class":139},"SECURE_SSL_REDIRECT",[133,7658,144],{"class":143},[133,7660,453],{"class":139},[133,7662,7663,7665,7667],{"class":135,"line":456},[133,7664,469],{"class":139},[133,7666,144],{"class":143},[133,7668,453],{"class":139},[133,7670,7671,7673,7675],{"class":135,"line":466},[133,7672,479],{"class":139},[133,7674,144],{"class":143},[133,7676,453],{"class":139},[10,7678,7679],{},"👉 Ensures Django only serves secure traffic",[36,7681],{},[39,7683,7685],{"id":7684},"auto-renewal-important","🔁 Auto-Renewal (Important)",[10,7687,7688],{},"Let’s Encrypt certificates expire every 90 days.",[10,7690,7691],{},"Test renewal:",[123,7693,7695],{"className":224,"code":7694,"language":226,"meta":128,"style":128},"sudo certbot renew --dry-run\n",[130,7696,7697],{"__ignoreMap":128},[133,7698,7699,7701,7703,7706],{"class":135,"line":136},[133,7700,293],{"class":233},[133,7702,413],{"class":173},[133,7704,7705],{"class":173}," renew",[133,7707,7708],{"class":139}," --dry-run\n",[10,7710,7711],{},"👉 Certbot usually installs automatic renewal via cron",[36,7713],{},[39,7715,7717],{"id":7716},"common-issues-and-fixes","🔥 Common Issues (and Fixes)",[36,7719],{},[118,7721,7723],{"id":7722},"domain-not-pointing-to-server","🔴 Domain not pointing to server",[10,7725,1701],{},[17,7727,7728,7731],{},[20,7729,7730],{},"Update DNS records",[20,7732,7733],{},"Wait for propagation",[118,7735,5584],{"id":5583},[10,7737,1701],{},[123,7739,7740],{"className":224,"code":328,"language":226,"meta":128,"style":128},[130,7741,7742],{"__ignoreMap":128},[133,7743,7744,7746,7748],{"class":135,"line":136},[133,7745,293],{"class":233},[133,7747,337],{"class":173},[133,7749,340],{"class":139},[36,7751],{},[118,7753,7755],{"id":7754},"port-80443-blocked","🔴 Port 80\u002F443 blocked",[10,7757,1701],{},[123,7759,7761],{"className":224,"code":7760,"language":226,"meta":128,"style":128},"sudo ufw allow 'Nginx Full'\n",[130,7762,7763],{"__ignoreMap":128},[133,7764,7765,7767,7769,7771],{"class":135,"line":136},[133,7766,293],{"class":233},[133,7768,7150],{"class":173},[133,7770,7153],{"class":173},[133,7772,7773],{"class":173}," 'Nginx Full'\n",[36,7775],{},[118,7777,7779],{"id":7778},"certbot-cannot-verify-domain","🔴 Certbot cannot verify domain",[10,7781,7782],{},"Cause:",[17,7784,7785,7788],{},[20,7786,7787],{},"Incorrect DNS",[20,7789,7790],{},"Server not reachable",[36,7792],{},[39,7794,1794],{"id":1793},[36,7796],{},[118,7798,7800],{"id":7799},"check-certbot-logs","Check Certbot logs",[123,7802,7804],{"className":224,"code":7803,"language":226,"meta":128,"style":128},"sudo journalctl -u certbot\n",[130,7805,7806],{"__ignoreMap":128},[133,7807,7808,7810,7813,7815],{"class":135,"line":136},[133,7809,293],{"class":233},[133,7811,7812],{"class":173}," journalctl",[133,7814,587],{"class":139},[133,7816,7817],{"class":173}," certbot\n",[36,7819],{},[118,7821,4904],{"id":4903},[123,7823,7824],{"className":224,"code":4092,"language":226,"meta":128,"style":128},[130,7825,7826],{"__ignoreMap":128},[133,7827,7828,7830,7832,7834],{"class":135,"line":136},[133,7829,293],{"class":233},[133,7831,596],{"class":173},[133,7833,599],{"class":139},[133,7835,602],{"class":173},[36,7837],{},[118,7839,7841],{"id":7840},"test-ssl","Test SSL",[123,7843,7845],{"className":224,"code":7844,"language":226,"meta":128,"style":128},"curl -I https:\u002F\u002Fyour-domain.com\n",[130,7846,7847],{"__ignoreMap":128},[133,7848,7849,7851,7854],{"class":135,"line":136},[133,7850,4020],{"class":233},[133,7852,7853],{"class":139}," -I",[133,7855,7856],{"class":173}," https:\u002F\u002Fyour-domain.com\n",[36,7858],{},[39,7860,7862],{"id":7861},"https-checklist","✅ HTTPS Checklist",[17,7864,7866,7872,7878,7884,7890,7896],{"className":7865},[46],[20,7867,7869,7871],{"className":7868},[50],[52,7870],{"disabled":54,"type":55}," Domain points to server",[20,7873,7875,7877],{"className":7874},[50],[52,7876],{"disabled":54,"type":55}," Certbot installed",[20,7879,7881,7883],{"className":7880},[50],[52,7882],{"disabled":54,"type":55}," Certificate issued",[20,7885,7887,7889],{"className":7886},[50],[52,7888],{"disabled":54,"type":55}," HTTPS working",[20,7891,7893,7895],{"className":7892},[50],[52,7894],{"disabled":54,"type":55}," Auto-renewal configured",[20,7897,7899,7901],{"className":7898},[50],[52,7900],{"disabled":54,"type":55}," Django secure settings enabled",[36,7903],{},[758,7905,7907],{"title":7906,"type":761},"Once HTTPS is enabled, finish the launch review",[10,7908,7909,7910,7913,7914,7916],{},"Re-check the base ",[244,7911,7912],{"href":307},"Django deployment guide"," and work through the ",[244,7915,1898],{"href":1897}," before you open the site to users.",[36,7918],{},[39,7920,822],{"id":821},[17,7922,7923,7927,7931],{},[20,7924,7925],{},[244,7926,308],{"href":307},[20,7928,7929],{},[244,7930,788],{"href":787},[20,7932,7933],{},[244,7934,7935],{"href":1897},"Django production checklist",[36,7937],{},[39,7939,850],{"id":849},[118,7941,7943],{"id":7942},"is-https-required","Is HTTPS required?",[10,7945,7946],{},"Yes.",[10,7948,7949],{},"Modern browsers:",[17,7951,7952,7955],{},[20,7953,7954],{},"Warn users",[20,7956,7957],{},"Block some features without HTTPS",[36,7959],{},[118,7961,7963],{"id":7962},"does-lets-encrypt-cost-money","Does Let’s Encrypt cost money?",[10,7965,7966],{},"No.",[10,7968,7969],{},"👉 It’s free and widely used",[36,7971],{},[118,7973,7975],{"id":7974},"do-i-need-a-domain","Do I need a domain?",[10,7977,7946],{},[10,7979,7980],{},"👉 Let’s Encrypt requires a valid domain name",[36,7982],{},[39,7984,905],{"id":904},[10,7986,7987],{},"HTTPS is:",[17,7989,7990,7993,7996],{},[20,7991,7992],{},"Essential for security",[20,7994,7995],{},"Required for production",[20,7997,7998],{},"Easy to set up with Certbot",[36,8000],{},[10,8002,924],{},[10,8004,8005],{},"Using a pre-configured setup with HTTPS included saves time and avoids errors.",[929,8007,8008],{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}",{"title":128,"searchDepth":466,"depth":466,"links":8010},[8011,8012,8013,8019,8020,8021,8027,8032,8033,8034,8039],{"id":7452,"depth":456,"text":7453},{"id":7510,"depth":456,"text":7511},{"id":7525,"depth":456,"text":7526,"children":8014},[8015,8016,8017,8018],{"id":7529,"depth":466,"text":7530},{"id":7561,"depth":466,"text":7562},{"id":7584,"depth":466,"text":7585},{"id":7619,"depth":466,"text":7620},{"id":7640,"depth":456,"text":7641},{"id":7684,"depth":456,"text":7685},{"id":7716,"depth":456,"text":7717,"children":8022},[8023,8024,8025,8026],{"id":7722,"depth":466,"text":7723},{"id":5583,"depth":466,"text":5584},{"id":7754,"depth":466,"text":7755},{"id":7778,"depth":466,"text":7779},{"id":1793,"depth":456,"text":1794,"children":8028},[8029,8030,8031],{"id":7799,"depth":466,"text":7800},{"id":4903,"depth":466,"text":4904},{"id":7840,"depth":466,"text":7841},{"id":7861,"depth":456,"text":7862},{"id":821,"depth":456,"text":822},{"id":849,"depth":456,"text":850,"children":8035},[8036,8037,8038],{"id":7942,"depth":466,"text":7943},{"id":7962,"depth":466,"text":7963},{"id":7974,"depth":466,"text":7975},{"id":904,"depth":456,"text":905},"Security","Learn how to secure your Django application with HTTPS using Nginx and Let’s Encrypt. This step-by-step guide covers everything from installing Certbot to configuring Nginx for SSL, ensuring your site is safe and trusted by browsers.",{},"\u002Fhow-to-set-up-https-for-django-nginx-lets-encrypt",[307,1897,787],"conversion",{"title":7412,"description":8041},"how-to-set-up-https-for-django-nginx-lets-encrypt",[979,1463,8049,8050],"lets-encrypt","https","IUXLZ6aLAEY6-r9FOe8fC1y8yRQtyqHBvCXy9bSjsDg",{"id":8053,"title":8054,"body":8055,"category":8742,"description":8743,"extension":969,"meta":8744,"navigation":54,"path":8745,"priority":972,"related":8746,"role":2035,"section":8747,"seo":8748,"stem":8749,"tags":8750,"__hash__":8752},"articles\u002Fzero-downtime-django-deployment-gunicorn-reload-strategy.md","Zero Downtime Django Deployment (Gunicorn Reload Strategy)",{"type":7,"value":8056,"toc":8713},[8057,8060,8071,8074,8084,8086,8090,8092,8108,8111,8113,8117,8120,8131,8133,8135,8146,8150,8154,8171,8173,8177,8198,8200,8204,8216,8220,8237,8241,8255,8258,8260,8264,8267,8292,8295,8297,8301,8303,8307,8321,8324,8327,8341,8343,8347,8350,8358,8360,8368,8370,8374,8382,8384,8386,8388,8390,8402,8405,8421,8423,8431,8434,8437,8445,8447,8451,8489,8491,8495,8498,8573,8575,8584,8587,8589,8593,8596,8607,8610,8612,8628,8630,8632,8646,8648,8650,8654,8662,8664,8668,8671,8679,8681,8685,8687,8690,8692,8694,8697,8702,8704,8707,8710],[10,8058,8059],{},"When you deploy a new version of your Django app, you don’t want:",[17,8061,8062,8065,8068],{},[20,8063,8064],{},"❌ Downtime",[20,8066,8067],{},"❌ 502 errors",[20,8069,8070],{},"❌ Failed requests",[10,8072,8073],{},"This guide shows you how to deploy updates without interrupting users, using:",[17,8075,8076,8079,8081],{},[20,8077,8078],{},"Gunicorn reload",[20,8080,5948],{},[20,8082,8083],{},"systemd",[36,8085],{},[39,8087,8089],{"id":8088},"quick-method-safe-reload","⚡ Quick Method (Safe Reload)",[10,8091,3778],{},[123,8093,8095],{"className":224,"code":8094,"language":226,"meta":128,"style":128},"sudo systemctl reload gunicorn\n",[130,8096,8097],{"__ignoreMap":128},[133,8098,8099,8101,8103,8106],{"class":135,"line":136},[133,8100,293],{"class":233},[133,8102,296],{"class":173},[133,8104,8105],{"class":173}," reload",[133,8107,302],{"class":173},[10,8109,8110],{},"👉 This reloads your app without dropping connections",[36,8112],{},[39,8114,8116],{"id":8115},"how-zero-downtime-works","🧠 How Zero Downtime Works",[10,8118,8119],{},"Gunicorn supports graceful reloads:",[17,8121,8122,8125,8128],{},[20,8123,8124],{},"Old workers finish active requests",[20,8126,8127],{},"New workers start with updated code",[20,8129,8130],{},"No interruption for users",[36,8132],{},[39,8134,1066],{"id":1065},[17,8136,8137,8140,8143],{},[20,8138,8139],{},"Django deployed with Gunicorn + Nginx",[20,8141,8142],{},"Working systemd service",[20,8144,8145],{},"App already running",[39,8147,8149],{"id":8148},"step-by-step-deployment-workflow","🧪 Step-by-Step Deployment Workflow",[118,8151,8153],{"id":8152},"_1-pull-latest-code","1. Pull latest code",[123,8155,8157],{"className":224,"code":8156,"language":226,"meta":128,"style":128},"cd \u002Fvar\u002Fwww\u002Fmyproject\ngit pull\n",[130,8158,8159,8165],{"__ignoreMap":128},[133,8160,8161,8163],{"class":135,"line":136},[133,8162,2175],{"class":139},[133,8164,513],{"class":173},[133,8166,8167,8169],{"class":135,"line":456},[133,8168,666],{"class":233},[133,8170,669],{"class":173},[36,8172],{},[118,8174,8176],{"id":8175},"_2-install-dependencies","2. Install dependencies",[123,8178,8180],{"className":224,"code":8179,"language":226,"meta":128,"style":128},"source venv\u002Fbin\u002Factivate\npip install -r requirements.txt\n",[130,8181,8182,8188],{"__ignoreMap":128},[133,8183,8184,8186],{"class":135,"line":136},[133,8185,2206],{"class":139},[133,8187,2209],{"class":173},[133,8189,8190,8192,8194,8196],{"class":135,"line":456},[133,8191,674],{"class":233},[133,8193,677],{"class":173},[133,8195,680],{"class":139},[133,8197,683],{"class":173},[36,8199],{},[118,8201,8203],{"id":8202},"_3-apply-migrations","3. Apply migrations",[123,8205,8206],{"className":224,"code":376,"language":226,"meta":128,"style":128},[130,8207,8208],{"__ignoreMap":128},[133,8209,8210,8212,8214],{"class":135,"line":136},[133,8211,127],{"class":233},[133,8213,236],{"class":173},[133,8215,387],{"class":173},[118,8217,8219],{"id":8218},"_4-collect-static-files","4. Collect static files",[123,8221,8223],{"className":224,"code":8222,"language":226,"meta":128,"style":128},"python manage.py collectstatic --noinput\n",[130,8224,8225],{"__ignoreMap":128},[133,8226,8227,8229,8231,8234],{"class":135,"line":136},[133,8228,127],{"class":233},[133,8230,236],{"class":173},[133,8232,8233],{"class":173}," collectstatic",[133,8235,8236],{"class":139}," --noinput\n",[118,8238,8240],{"id":8239},"_5-reload-gunicorn-zero-downtime","5. Reload Gunicorn (zero downtime)",[123,8242,8243],{"className":224,"code":8094,"language":226,"meta":128,"style":128},[130,8244,8245],{"__ignoreMap":128},[133,8246,8247,8249,8251,8253],{"class":135,"line":136},[133,8248,293],{"class":233},[133,8250,296],{"class":173},[133,8252,8105],{"class":173},[133,8254,302],{"class":173},[10,8256,8257],{},"👉 This is the key step for zero downtime",[36,8259],{},[39,8261,8263],{"id":8262},"alternative-manual-signal-reload","🔁 Alternative: Manual Signal Reload",[10,8265,8266],{},"If not using systemd:",[123,8268,8270],{"className":224,"code":8269,"language":226,"meta":128,"style":128},"kill -HUP \u003Cgunicorn-master-pid>\n",[130,8271,8272],{"__ignoreMap":128},[133,8273,8274,8277,8280,8283,8286,8289],{"class":135,"line":136},[133,8275,8276],{"class":139},"kill",[133,8278,8279],{"class":139}," -HUP",[133,8281,8282],{"class":143}," \u003C",[133,8284,8285],{"class":173},"gunicorn-master-pi",[133,8287,8288],{"class":169},"d",[133,8290,8291],{"class":143},">\n",[10,8293,8294],{},"👉 Sends reload signal directly",[36,8296],{},[39,8298,8300],{"id":8299},"common-mistakes-and-fixes","🔥 Common Mistakes (and Fixes)",[36,8302],{},[118,8304,8306],{"id":8305},"using-restart-instead-of-reload","🔴 Using restart instead of reload",[123,8308,8309],{"className":224,"code":6132,"language":226,"meta":128,"style":128},[130,8310,8311],{"__ignoreMap":128},[133,8312,8313,8315,8317,8319],{"class":135,"line":136},[133,8314,293],{"class":233},[133,8316,296],{"class":173},[133,8318,709],{"class":173},[133,8320,302],{"class":173},[10,8322,8323],{},"👉 Causes downtime",[10,8325,8326],{},"✅ Use:",[123,8328,8329],{"className":224,"code":8094,"language":226,"meta":128,"style":128},[130,8330,8331],{"__ignoreMap":128},[133,8332,8333,8335,8337,8339],{"class":135,"line":136},[133,8334,293],{"class":233},[133,8336,296],{"class":173},[133,8338,8105],{"class":173},[133,8340,302],{"class":173},[36,8342],{},[118,8344,8346],{"id":8345},"broken-code-deployed","🔴 Broken code deployed",[10,8348,8349],{},"If new code crashes:",[17,8351,8352,8355],{},[20,8353,8354],{},"Gunicorn reload fails",[20,8356,8357],{},"App becomes unstable",[10,8359,1701],{},[17,8361,8362,8365],{},[20,8363,8364],{},"Test before deploying",[20,8366,8367],{},"Check logs immediately",[36,8369],{},[118,8371,8373],{"id":8372},"long-running-requests","🔴 Long-running requests",[17,8375,8376,8379],{},[20,8377,8378],{},"Old workers wait until finished",[20,8380,8381],{},"Reload may take longer",[36,8383],{},[39,8385,1794],{"id":1793},[36,8387],{},[10,8389,6410],{},[123,8391,8392],{"className":224,"code":4220,"language":226,"meta":128,"style":128},[130,8393,8394],{"__ignoreMap":128},[133,8395,8396,8398,8400],{"class":135,"line":136},[133,8397,584],{"class":233},[133,8399,587],{"class":139},[133,8401,302],{"class":173},[10,8403,8404],{},"Check running processes",[123,8406,8407],{"className":224,"code":7179,"language":226,"meta":128,"style":128},[130,8408,8409],{"__ignoreMap":128},[133,8410,8411,8413,8415,8417,8419],{"class":135,"line":136},[133,8412,6345],{"class":233},[133,8414,6348],{"class":173},[133,8416,6351],{"class":143},[133,8418,6354],{"class":233},[133,8420,302],{"class":173},[10,8422,7634],{},[17,8424,8425,8428],{},[20,8426,8427],{},"Old workers shutting down",[20,8429,8430],{},"New workers starting",[10,8432,8433],{},"Verify deployment worked",[10,8435,8436],{},"Reload your site:",[17,8438,8439,8442],{},[20,8440,8441],{},"Check new features",[20,8443,8444],{},"Check logs for errors",[36,8446],{},[39,8448,8450],{"id":8449},"zero-downtime-checklist","✅ Zero Downtime Checklist",[17,8452,8454,8460,8466,8472,8478,8484],{"className":8453},[46],[20,8455,8457,8459],{"className":8456},[50],[52,8458],{"disabled":54,"type":55}," Code updated",[20,8461,8463,8465],{"className":8462},[50],[52,8464],{"disabled":54,"type":55}," Dependencies installed",[20,8467,8469,8471],{"className":8468},[50],[52,8470],{"disabled":54,"type":55}," Migrations applied",[20,8473,8475,8477],{"className":8474},[50],[52,8476],{"disabled":54,"type":55}," Static files collected",[20,8479,8481,8483],{"className":8480},[50],[52,8482],{"disabled":54,"type":55}," Gunicorn reloaded (not restarted)",[20,8485,8487,7250],{"className":8486},[50],[52,8488],{"disabled":54,"type":55},[36,8490],{},[39,8492,8494],{"id":8493},"improved-deployment-script","🚀 Improved Deployment Script",[10,8496,8497],{},"Create a simple deploy script:",[123,8499,8501],{"className":224,"code":8500,"language":226,"meta":128,"style":128},"#!\u002Fbin\u002Fbash\n\ncd \u002Fvar\u002Fwww\u002Fmyproject\n\ngit pull\nsource venv\u002Fbin\u002Factivate\npip install -r requirements.txt\npython manage.py migrate\npython manage.py collectstatic --noinput\nsudo systemctl reload gunicorn\n",[130,8502,8503,8509,8513,8519,8523,8529,8535,8545,8553,8563],{"__ignoreMap":128},[133,8504,8505],{"class":135,"line":136},[133,8506,8508],{"class":8507},"sJ8bj","#!\u002Fbin\u002Fbash\n",[133,8510,8511],{"class":135,"line":456},[133,8512,1245],{"emptyLinePlaceholder":54},[133,8514,8515,8517],{"class":135,"line":466},[133,8516,2175],{"class":139},[133,8518,513],{"class":173},[133,8520,8521],{"class":135,"line":476},[133,8522,1245],{"emptyLinePlaceholder":54},[133,8524,8525,8527],{"class":135,"line":702},[133,8526,666],{"class":233},[133,8528,669],{"class":173},[133,8530,8531,8533],{"class":135,"line":1126},[133,8532,2206],{"class":139},[133,8534,2209],{"class":173},[133,8536,8537,8539,8541,8543],{"class":135,"line":1138},[133,8538,674],{"class":233},[133,8540,677],{"class":173},[133,8542,680],{"class":139},[133,8544,683],{"class":173},[133,8546,8547,8549,8551],{"class":135,"line":1293},[133,8548,127],{"class":233},[133,8550,236],{"class":173},[133,8552,387],{"class":173},[133,8554,8555,8557,8559,8561],{"class":135,"line":1301},[133,8556,127],{"class":233},[133,8558,236],{"class":173},[133,8560,8233],{"class":173},[133,8562,8236],{"class":139},[133,8564,8565,8567,8569,8571],{"class":135,"line":1310},[133,8566,293],{"class":233},[133,8568,296],{"class":173},[133,8570,8105],{"class":173},[133,8572,302],{"class":173},[10,8574,3778],{},[123,8576,8578],{"className":224,"code":8577,"language":226,"meta":128,"style":128},".\u002Fdeploy.sh\n",[130,8579,8580],{"__ignoreMap":128},[133,8581,8582],{"class":135,"line":136},[133,8583,8577],{"class":233},[10,8585,8586],{},"👉 This makes deployments consistent and safe",[36,8588],{},[39,8590,8592],{"id":8591},"advanced-rolling-deployments-optional","⚡ Advanced: Rolling Deployments (Optional)",[10,8594,8595],{},"For higher traffic setups:",[17,8597,8598,8601,8604],{},[20,8599,8600],{},"Multiple Gunicorn instances",[20,8602,8603],{},"Load balancing",[20,8605,8606],{},"Rolling updates",[10,8608,8609],{},"👉 Not required for most setups but good to know for scaling",[36,8611],{},[758,8613,8615],{"title":8614,"type":761},"Build a safer deployment workflow around reloads",[10,8616,8617,8618,8620,8621,8624,8625,8627],{},"Use the base ",[244,8619,4396],{"href":307},", the ",[244,8622,8623],{"href":781},"Docker production guide",", and the ",[244,8626,1898],{"href":1897}," to turn reloads into a repeatable release process.",[36,8629],{},[39,8631,822],{"id":821},[17,8633,8634,8638,8642],{},[20,8635,8636],{},[244,8637,308],{"href":307},[20,8639,8640],{},[244,8641,782],{"href":781},[20,8643,8644],{},[244,8645,7935],{"href":1897},[36,8647],{},[39,8649,850],{"id":849},[118,8651,8653],{"id":8652},"whats-the-difference-between-reload-and-restart","What’s the difference between reload and restart?",[17,8655,8656,8659],{},[20,8657,8658],{},"Reload → no downtime",[20,8660,8661],{},"Restart → downtime",[36,8663],{},[118,8665,8667],{"id":8666},"is-zero-downtime-guaranteed","Is zero downtime guaranteed?",[10,8669,8670],{},"Mostly—but depends on:",[17,8672,8673,8676],{},[20,8674,8675],{},"Code stability",[20,8677,8678],{},"Request duration",[36,8680],{},[118,8682,8684],{"id":8683},"do-i-need-docker-for-zero-downtime","Do I need Docker for zero downtime?",[10,8686,7966],{},[10,8688,8689],{},"Gunicorn alone supports graceful reloads.",[36,8691],{},[39,8693,905],{"id":904},[10,8695,8696],{},"Zero downtime deployment is achieved by:",[3762,8698,8699],{},[10,8700,8701],{},"Reloading Gunicorn instead of restarting it",[36,8703],{},[10,8705,8706],{},"If you deploy frequently…",[10,8708,8709],{},"A repeatable deployment workflow or script is essential.",[929,8711,8712],{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}",{"title":128,"searchDepth":466,"depth":466,"links":8714},[8715,8716,8717,8718,8725,8726,8731,8732,8733,8734,8735,8736,8741],{"id":8088,"depth":456,"text":8089},{"id":8115,"depth":456,"text":8116},{"id":1065,"depth":456,"text":1066},{"id":8148,"depth":456,"text":8149,"children":8719},[8720,8721,8722,8723,8724],{"id":8152,"depth":466,"text":8153},{"id":8175,"depth":466,"text":8176},{"id":8202,"depth":466,"text":8203},{"id":8218,"depth":466,"text":8219},{"id":8239,"depth":466,"text":8240},{"id":8262,"depth":456,"text":8263},{"id":8299,"depth":456,"text":8300,"children":8727},[8728,8729,8730],{"id":8305,"depth":466,"text":8306},{"id":8345,"depth":466,"text":8346},{"id":8372,"depth":466,"text":8373},{"id":1793,"depth":456,"text":1794},{"id":8449,"depth":456,"text":8450},{"id":8493,"depth":456,"text":8494},{"id":8591,"depth":456,"text":8592},{"id":821,"depth":456,"text":822},{"id":849,"depth":456,"text":850,"children":8737},[8738,8739,8740],{"id":8652,"depth":466,"text":8653},{"id":8666,"depth":466,"text":8667},{"id":8683,"depth":466,"text":8684},{"id":904,"depth":456,"text":905},"Operations","Learn how to achieve zero downtime when deploying Django applications with Gunicorn. This guide covers strategies for gracefully reloading your application without interrupting user experience.",{},"\u002Fzero-downtime-django-deployment-gunicorn-reload-strategy",[307,1897,781],"optimize",{"title":8054,"description":8743},"zero-downtime-django-deployment-gunicorn-reload-strategy",[979,2302,4451,8751],"uptime","8YJppO-TssNEVShepq-Nav-FJb6qQcFEW8ARPrWDJq8",1776665239767]