[{"data":1,"prerenderedAt":1664},["ShallowReactive",2],{"\u002Ffix-issues\u002Fflask-app-not-reloading-after-deploy":3},{"id":4,"title":5,"body":6,"description":1654,"extension":1655,"meta":1656,"navigation":507,"path":1660,"seo":1661,"stem":1662,"__hash__":1663},"content\u002Ffix-issues\u002Fflask-app-not-reloading-after-deploy.md","Flask App Not Reloading After Deploy",{"type":7,"value":8,"toc":1621},"minimark",[9,13,17,22,25,157,164,167,171,174,177,193,197,202,205,237,240,264,267,271,274,291,294,298,301,352,355,359,362,389,398,402,405,428,435,439,442,458,461,478,481,560,569,573,576,602,609,613,620,641,644,648,651,675,690,693,716,720,723,726,761,764,771,775,778,807,810,814,817,867,870,894,898,901,928,934,938,941,944,1052,1055,1067,1070,1074,1158,1162,1165,1214,1217,1250,1253,1314,1317,1353,1356,1383,1386,1406,1409,1444,1447,1467,1471,1540,1544,1564,1568,1572,1575,1583,1586,1590,1593,1597,1600,1604,1610,1614,1617],[10,11,5],"h1",{"id":12},"flask-app-not-reloading-after-deploy",[14,15,16],"p",{},"If your Flask app is still serving old code after deployment, this guide shows you how to force the correct production reload path and verify that the new release is actually running. It covers Gunicorn, systemd, Nginx, static assets, and common deployment mistakes that prevent updated code from appearing.",[18,19,21],"h2",{"id":20},"quick-fix-quick-setup","Quick Fix \u002F Quick Setup",[14,23,24],{},"Run the standard restart and verification path first:",[26,27,32],"pre",{"className":28,"code":29,"language":30,"meta":31,"style":31},"language-bash shiki shiki-themes github-light github-dark","sudo systemctl daemon-reload\nsudo systemctl restart yourapp\nsudo systemctl status yourapp --no-pager\nsudo nginx -t && sudo systemctl reload nginx\nps aux | grep gunicorn\nreadlink -f \u002Fproc\u002F$(pgrep -n -f 'gunicorn.*yourapp')\u002Fcwd\n","bash","",[33,34,35,51,64,81,106,125],"code",{"__ignoreMap":31},[36,37,40,44,48],"span",{"class":38,"line":39},"line",1,[36,41,43],{"class":42},"sScJk","sudo",[36,45,47],{"class":46},"sZZnC"," systemctl",[36,49,50],{"class":46}," daemon-reload\n",[36,52,54,56,58,61],{"class":38,"line":53},2,[36,55,43],{"class":42},[36,57,47],{"class":46},[36,59,60],{"class":46}," restart",[36,62,63],{"class":46}," yourapp\n",[36,65,67,69,71,74,77],{"class":38,"line":66},3,[36,68,43],{"class":42},[36,70,47],{"class":46},[36,72,73],{"class":46}," status",[36,75,76],{"class":46}," yourapp",[36,78,80],{"class":79},"sj4cs"," --no-pager\n",[36,82,84,86,89,92,96,98,100,103],{"class":38,"line":83},4,[36,85,43],{"class":42},[36,87,88],{"class":46}," nginx",[36,90,91],{"class":79}," -t",[36,93,95],{"class":94},"sVt8B"," && ",[36,97,43],{"class":42},[36,99,47],{"class":46},[36,101,102],{"class":46}," reload",[36,104,105],{"class":46}," nginx\n",[36,107,109,112,115,119,122],{"class":38,"line":108},5,[36,110,111],{"class":42},"ps",[36,113,114],{"class":46}," aux",[36,116,118],{"class":117},"szBVR"," |",[36,120,121],{"class":42}," grep",[36,123,124],{"class":46}," gunicorn\n",[36,126,128,131,134,137,140,143,146,148,151,154],{"class":38,"line":127},6,[36,129,130],{"class":42},"readlink",[36,132,133],{"class":79}," -f",[36,135,136],{"class":46}," \u002Fproc\u002F",[36,138,139],{"class":94},"$(",[36,141,142],{"class":42},"pgrep",[36,144,145],{"class":79}," -n",[36,147,133],{"class":79},[36,149,150],{"class":46}," 'gunicorn.*yourapp'",[36,152,153],{"class":94},")",[36,155,156],{"class":46},"\u002Fcwd\n",[14,158,159,160,163],{},"Replace ",[33,161,162],{},"yourapp"," with your actual systemd service name.",[14,165,166],{},"This fixes the most common case: code was deployed, but Gunicorn or Nginx is still serving the previous release or the service is pointing at the wrong directory.",[18,168,170],{"id":169},"whats-happening","What’s Happening",[14,172,173],{},"In production, Flask code changes do not apply automatically unless the serving process is restarted or reloaded correctly.",[14,175,176],{},"Typical failure points:",[178,179,180,184,187,190],"ul",{},[181,182,183],"li",{},"Gunicorn workers are still running code already loaded in memory",[181,185,186],{},"systemd is starting Gunicorn from an old release path or virtualenv",[181,188,189],{},"Nginx is proxying to the wrong socket or serving stale static files",[181,191,192],{},"a containerized deployment is still running the previous image or mount",[18,194,196],{"id":195},"step-by-step-guide","Step-by-Step Guide",[198,199,201],"h3",{"id":200},"_1-confirm-the-new-code-exists-on-disk","1. Confirm the new code exists on disk",[14,203,204],{},"Check that the latest release is actually present in the path you expect:",[26,206,208],{"className":28,"code":207,"language":30,"meta":31,"style":31},"pwd\nls -la\ngit rev-parse --short HEAD\n",[33,209,210,215,223],{"__ignoreMap":31},[36,211,212],{"class":38,"line":39},[36,213,214],{"class":79},"pwd\n",[36,216,217,220],{"class":38,"line":53},[36,218,219],{"class":42},"ls",[36,221,222],{"class":79}," -la\n",[36,224,225,228,231,234],{"class":38,"line":66},[36,226,227],{"class":42},"git",[36,229,230],{"class":46}," rev-parse",[36,232,233],{"class":79}," --short",[36,235,236],{"class":46}," HEAD\n",[14,238,239],{},"If you use release directories:",[26,241,243],{"className":28,"code":242,"language":30,"meta":31,"style":31},"ls -la \u002Fvar\u002Fwww\u002Fyourapp\nreadlink -f \u002Fvar\u002Fwww\u002Fyourapp\u002Fcurrent\n",[33,244,245,255],{"__ignoreMap":31},[36,246,247,249,252],{"class":38,"line":39},[36,248,219],{"class":42},[36,250,251],{"class":79}," -la",[36,253,254],{"class":46}," \u002Fvar\u002Fwww\u002Fyourapp\n",[36,256,257,259,261],{"class":38,"line":53},[36,258,130],{"class":42},[36,260,133],{"class":79},[36,262,263],{"class":46}," \u002Fvar\u002Fwww\u002Fyourapp\u002Fcurrent\n",[14,265,266],{},"Verify that the current release contains the expected code changes.",[198,268,270],{"id":269},"_2-verify-which-process-is-serving-traffic","2. Verify which process is serving traffic",[14,272,273],{},"Find the active Gunicorn process:",[26,275,277],{"className":28,"code":276,"language":30,"meta":31,"style":31},"ps aux | grep gunicorn\n",[33,278,279],{"__ignoreMap":31},[36,280,281,283,285,287,289],{"class":38,"line":39},[36,282,111],{"class":42},[36,284,114],{"class":46},[36,286,118],{"class":117},[36,288,121],{"class":42},[36,290,124],{"class":46},[14,292,293],{},"Identify the Gunicorn master and worker processes that are serving the live app.",[198,295,297],{"id":296},"_3-check-the-running-gunicorn-working-directory","3. Check the running Gunicorn working directory",[14,299,300],{},"Inspect the current working directory of the running Gunicorn process:",[26,302,304],{"className":28,"code":303,"language":30,"meta":31,"style":31},"readlink -f \u002Fproc\u002F$(pgrep -n -f 'gunicorn.*yourapp')\u002Fcwd\nls -l \u002Fproc\u002F$(pgrep -n -f 'gunicorn.*yourapp')\u002Fexe\n",[33,305,306,328],{"__ignoreMap":31},[36,307,308,310,312,314,316,318,320,322,324,326],{"class":38,"line":39},[36,309,130],{"class":42},[36,311,133],{"class":79},[36,313,136],{"class":46},[36,315,139],{"class":94},[36,317,142],{"class":42},[36,319,145],{"class":79},[36,321,133],{"class":79},[36,323,150],{"class":46},[36,325,153],{"class":94},[36,327,156],{"class":46},[36,329,330,332,335,337,339,341,343,345,347,349],{"class":38,"line":53},[36,331,219],{"class":42},[36,333,334],{"class":79}," -l",[36,336,136],{"class":46},[36,338,139],{"class":94},[36,340,142],{"class":42},[36,342,145],{"class":79},[36,344,133],{"class":79},[36,346,150],{"class":46},[36,348,153],{"class":94},[36,350,351],{"class":46},"\u002Fexe\n",[14,353,354],{},"If this points to an old release, old virtualenv, or unexpected path, the service definition is wrong or the app was not restarted correctly.",[198,356,358],{"id":357},"_4-restart-the-flask-app-service","4. Restart the Flask app service",[14,360,361],{},"Restart the systemd service that runs Gunicorn:",[26,363,365],{"className":28,"code":364,"language":30,"meta":31,"style":31},"sudo systemctl restart yourapp\nsudo systemctl status yourapp --no-pager\n",[33,366,367,377],{"__ignoreMap":31},[36,368,369,371,373,375],{"class":38,"line":39},[36,370,43],{"class":42},[36,372,47],{"class":46},[36,374,60],{"class":46},[36,376,63],{"class":46},[36,378,379,381,383,385,387],{"class":38,"line":53},[36,380,43],{"class":42},[36,382,47],{"class":46},[36,384,73],{"class":46},[36,386,76],{"class":46},[36,388,80],{"class":79},[14,390,391,392,397],{},"If the restart fails, check ",[393,394,396],"a",{"href":395},"\u002Ffix-issues\u002Fflask-gunicorn-service-failed-to-start","Flask Gunicorn Service Failed to Start",".",[198,399,401],{"id":400},"_5-reload-systemd-if-the-unit-file-changed","5. Reload systemd if the unit file changed",[14,403,404],{},"If you changed the unit file, drop-ins, or environment file references:",[26,406,408],{"className":28,"code":407,"language":30,"meta":31,"style":31},"sudo systemctl daemon-reload\nsudo systemctl restart yourapp\n",[33,409,410,418],{"__ignoreMap":31},[36,411,412,414,416],{"class":38,"line":39},[36,413,43],{"class":42},[36,415,47],{"class":46},[36,417,50],{"class":46},[36,419,420,422,424,426],{"class":38,"line":53},[36,421,43],{"class":42},[36,423,47],{"class":46},[36,425,60],{"class":46},[36,427,63],{"class":46},[14,429,430,431,434],{},"Without ",[33,432,433],{},"daemon-reload",", systemd may continue using the previous unit definition.",[198,436,438],{"id":437},"_6-validate-the-systemd-unit-paths","6. Validate the systemd unit paths",[14,440,441],{},"Inspect the live unit configuration:",[26,443,445],{"className":28,"code":444,"language":30,"meta":31,"style":31},"sudo systemctl cat yourapp\n",[33,446,447],{"__ignoreMap":31},[36,448,449,451,453,456],{"class":38,"line":39},[36,450,43],{"class":42},[36,452,47],{"class":46},[36,454,455],{"class":46}," cat",[36,457,63],{"class":46},[14,459,460],{},"Check these fields carefully:",[178,462,463,468,473],{},[181,464,465],{},[33,466,467],{},"WorkingDirectory",[181,469,470],{},[33,471,472],{},"ExecStart",[181,474,475],{},[33,476,477],{},"EnvironmentFile",[14,479,480],{},"Example correct unit:",[26,482,486],{"className":483,"code":484,"language":485,"meta":31,"style":31},"language-ini shiki shiki-themes github-light github-dark","[Unit]\nDescription=Gunicorn instance for yourapp\nAfter=network.target\n\n[Service]\nUser=www-data\nGroup=www-data\nWorkingDirectory=\u002Fvar\u002Fwww\u002Fyourapp\u002Fcurrent\nEnvironmentFile=\u002Fetc\u002Fyourapp.env\nExecStart=\u002Fvar\u002Fwww\u002Fyourapp\u002Fvenv\u002Fbin\u002Fgunicorn --workers 3 --bind unix:\u002Frun\u002Fyourapp.sock wsgi:app\n\n[Install]\nWantedBy=multi-user.target\n","ini",[33,487,488,493,498,503,509,514,519,525,531,537,543,548,554],{"__ignoreMap":31},[36,489,490],{"class":38,"line":39},[36,491,492],{},"[Unit]\n",[36,494,495],{"class":38,"line":53},[36,496,497],{},"Description=Gunicorn instance for yourapp\n",[36,499,500],{"class":38,"line":66},[36,501,502],{},"After=network.target\n",[36,504,505],{"class":38,"line":83},[36,506,508],{"emptyLinePlaceholder":507},true,"\n",[36,510,511],{"class":38,"line":108},[36,512,513],{},"[Service]\n",[36,515,516],{"class":38,"line":127},[36,517,518],{},"User=www-data\n",[36,520,522],{"class":38,"line":521},7,[36,523,524],{},"Group=www-data\n",[36,526,528],{"class":38,"line":527},8,[36,529,530],{},"WorkingDirectory=\u002Fvar\u002Fwww\u002Fyourapp\u002Fcurrent\n",[36,532,534],{"class":38,"line":533},9,[36,535,536],{},"EnvironmentFile=\u002Fetc\u002Fyourapp.env\n",[36,538,540],{"class":38,"line":539},10,[36,541,542],{},"ExecStart=\u002Fvar\u002Fwww\u002Fyourapp\u002Fvenv\u002Fbin\u002Fgunicorn --workers 3 --bind unix:\u002Frun\u002Fyourapp.sock wsgi:app\n",[36,544,546],{"class":38,"line":545},11,[36,547,508],{"emptyLinePlaceholder":507},[36,549,551],{"class":38,"line":550},12,[36,552,553],{},"[Install]\n",[36,555,557],{"class":38,"line":556},13,[36,558,559],{},"WantedBy=multi-user.target\n",[14,561,562,563,565,566,568],{},"Make sure the ",[33,564,467],{}," points to the active release and ",[33,567,472],{}," uses the correct Gunicorn binary.",[198,570,572],{"id":571},"_7-confirm-environment-variables-are-current","7. Confirm environment variables are current",[14,574,575],{},"If deploy-time settings changed, confirm the service is loading the right environment file:",[26,577,579],{"className":28,"code":578,"language":30,"meta":31,"style":31},"sudo systemctl show yourapp | grep -E 'Environment=|EnvironmentFiles='\n",[33,580,581],{"__ignoreMap":31},[36,582,583,585,587,590,592,594,596,599],{"class":38,"line":39},[36,584,43],{"class":42},[36,586,47],{"class":46},[36,588,589],{"class":46}," show",[36,591,76],{"class":46},[36,593,118],{"class":117},[36,595,121],{"class":42},[36,597,598],{"class":79}," -E",[36,600,601],{"class":46}," 'Environment=|EnvironmentFiles='\n",[14,603,604,605,397],{},"If variables changed, restart the service after updating the environment file. For deeper environment debugging, see ",[393,606,608],{"href":607},"\u002Ffix-issues\u002Fflask-environment-variables-not-loading-in-production","Flask Environment Variables Not Loading in Production",[198,610,612],{"id":611},"_8-verify-symlink-based-release-switching","8. Verify symlink-based release switching",[14,614,615,616,619],{},"If you deploy with versioned releases and a ",[33,617,618],{},"current"," symlink, make sure the symlink points to the new release:",[26,621,623],{"className":28,"code":622,"language":30,"meta":31,"style":31},"readlink -f \u002Fvar\u002Fwww\u002Fyourapp\u002Fcurrent\nls -la \u002Fvar\u002Fwww\u002Fyourapp\n",[33,624,625,633],{"__ignoreMap":31},[36,626,627,629,631],{"class":38,"line":39},[36,628,130],{"class":42},[36,630,133],{"class":79},[36,632,263],{"class":46},[36,634,635,637,639],{"class":38,"line":53},[36,636,219],{"class":42},[36,638,251],{"class":79},[36,640,254],{"class":46},[14,642,643],{},"If the symlink changed but Gunicorn is still serving the old release, restart the service so workers start from the new target.",[198,645,647],{"id":646},"_9-reload-nginx-if-upstream-or-static-paths-changed","9. Reload Nginx if upstream or static paths changed",[14,649,650],{},"Validate and reload Nginx:",[26,652,654],{"className":28,"code":653,"language":30,"meta":31,"style":31},"sudo nginx -t\nsudo systemctl reload nginx\n",[33,655,656,665],{"__ignoreMap":31},[36,657,658,660,662],{"class":38,"line":39},[36,659,43],{"class":42},[36,661,88],{"class":46},[36,663,664],{"class":79}," -t\n",[36,666,667,669,671,673],{"class":38,"line":53},[36,668,43],{"class":42},[36,670,47],{"class":46},[36,672,102],{"class":46},[36,674,105],{"class":46},[14,676,677,678,681,682,685,686,689],{},"If you changed ",[33,679,680],{},"proxy_pass",", a Unix socket path, ",[33,683,684],{},"root",", or ",[33,687,688],{},"alias",", Nginx must be reloaded.",[14,691,692],{},"To inspect active upstream configuration:",[26,694,696],{"className":28,"code":695,"language":30,"meta":31,"style":31},"sudo grep -R \"proxy_pass\\|root\\|alias\" \u002Fetc\u002Fnginx\u002Fsites-enabled \u002Fetc\u002Fnginx\u002Fconf.d\n",[33,697,698],{"__ignoreMap":31},[36,699,700,702,704,707,710,713],{"class":38,"line":39},[36,701,43],{"class":42},[36,703,121],{"class":46},[36,705,706],{"class":79}," -R",[36,708,709],{"class":46}," \"proxy_pass\\|root\\|alias\"",[36,711,712],{"class":46}," \u002Fetc\u002Fnginx\u002Fsites-enabled",[36,714,715],{"class":46}," \u002Fetc\u002Fnginx\u002Fconf.d\n",[198,717,719],{"id":718},"_10-rebuild-or-refresh-static-assets","10. Rebuild or refresh static assets",[14,721,722],{},"If templates or Python code changed but the UI still looks old, static files may be stale.",[14,724,725],{},"Validate the static path configured in Nginx and compare timestamps:",[26,727,729],{"className":28,"code":728,"language":30,"meta":31,"style":31},"find \u002Fvar\u002Fwww\u002Fyourapp\u002Fcurrent\u002Fstatic -type f | head\ncurl -I https:\u002F\u002Fyour-domain\u002Fstatic\u002Fapp.css\n",[33,730,731,750],{"__ignoreMap":31},[36,732,733,736,739,742,745,747],{"class":38,"line":39},[36,734,735],{"class":42},"find",[36,737,738],{"class":46}," \u002Fvar\u002Fwww\u002Fyourapp\u002Fcurrent\u002Fstatic",[36,740,741],{"class":79}," -type",[36,743,744],{"class":46}," f",[36,746,118],{"class":117},[36,748,749],{"class":42}," head\n",[36,751,752,755,758],{"class":38,"line":53},[36,753,754],{"class":42},"curl",[36,756,757],{"class":79}," -I",[36,759,760],{"class":46}," https:\u002F\u002Fyour-domain\u002Fstatic\u002Fapp.css\n",[14,762,763],{},"If your build pipeline generates assets, rebuild them before restarting the app.",[14,765,766,767,397],{},"If Nginx static handling is the issue, also review the static file setup in your main deployment path: ",[393,768,770],{"href":769},"\u002Fdeploy\u002Fdeploy-flask-with-nginx-plus-gunicorn-step-by-step-guide","Deploy Flask with Nginx + Gunicorn (Step-by-Step Guide)",[198,772,774],{"id":773},"_11-eliminate-browser-and-proxy-caching-during-validation","11. Eliminate browser and proxy caching during validation",[14,776,777],{},"Test without browser cache:",[26,779,781],{"className":28,"code":780,"language":30,"meta":31,"style":31},"curl -I https:\u002F\u002Fyour-domain\ncurl -I \"https:\u002F\u002Fyour-domain\u002F?v=$(date +%s)\"\n",[33,782,783,792],{"__ignoreMap":31},[36,784,785,787,789],{"class":38,"line":39},[36,786,754],{"class":42},[36,788,757],{"class":79},[36,790,791],{"class":46}," https:\u002F\u002Fyour-domain\n",[36,793,794,796,798,801,804],{"class":38,"line":53},[36,795,754],{"class":42},[36,797,757],{"class":79},[36,799,800],{"class":46}," \"https:\u002F\u002Fyour-domain\u002F?v=$(",[36,802,803],{"class":42},"date",[36,805,806],{"class":46}," +%s)\"\n",[14,808,809],{},"Use a private browser window and, if applicable, purge CDN or reverse proxy cache.",[198,811,813],{"id":812},"_12-rebuild-and-replace-containers-if-using-docker","12. Rebuild and replace containers if using Docker",[14,815,816],{},"If the app runs in containers, rebuild and recreate the service:",[26,818,820],{"className":28,"code":819,"language":30,"meta":31,"style":31},"docker compose build --no-cache\ndocker compose up -d\ndocker ps\ndocker compose logs --tail=100\n",[33,821,822,836,848,855],{"__ignoreMap":31},[36,823,824,827,830,833],{"class":38,"line":39},[36,825,826],{"class":42},"docker",[36,828,829],{"class":46}," compose",[36,831,832],{"class":46}," build",[36,834,835],{"class":79}," --no-cache\n",[36,837,838,840,842,845],{"class":38,"line":53},[36,839,826],{"class":42},[36,841,829],{"class":46},[36,843,844],{"class":46}," up",[36,846,847],{"class":79}," -d\n",[36,849,850,852],{"class":38,"line":66},[36,851,826],{"class":42},[36,853,854],{"class":46}," ps\n",[36,856,857,859,861,864],{"class":38,"line":83},[36,858,826],{"class":42},[36,860,829],{"class":46},[36,862,863],{"class":46}," logs",[36,865,866],{"class":79}," --tail=100\n",[14,868,869],{},"Check that the running container uses the latest image and correct mount paths:",[26,871,873],{"className":28,"code":872,"language":30,"meta":31,"style":31},"docker inspect \u003Ccontainer_name_or_id>\n",[33,874,875],{"__ignoreMap":31},[36,876,877,879,882,885,888,891],{"class":38,"line":39},[36,878,826],{"class":42},[36,880,881],{"class":46}," inspect",[36,883,884],{"class":117}," \u003C",[36,886,887],{"class":46},"container_name_or_i",[36,889,890],{"class":94},"d",[36,892,893],{"class":117},">\n",[198,895,897],{"id":896},"_13-use-a-controlled-gunicorn-reload-only-if-your-setup-supports-it","13. Use a controlled Gunicorn reload only if your setup supports it",[14,899,900],{},"If your setup uses a Gunicorn PID file, you can reload workers without a full service restart:",[26,902,904],{"className":28,"code":903,"language":30,"meta":31,"style":31},"sudo kill -HUP $(cat \u002Frun\u002Fgunicorn.pid)\n",[33,905,906],{"__ignoreMap":31},[36,907,908,910,913,916,919,922,925],{"class":38,"line":39},[36,909,43],{"class":42},[36,911,912],{"class":46}," kill",[36,914,915],{"class":79}," -HUP",[36,917,918],{"class":94}," $(",[36,920,921],{"class":42},"cat",[36,923,924],{"class":46}," \u002Frun\u002Fgunicorn.pid",[36,926,927],{"class":94},")\n",[14,929,930,931,397],{},"Use this only if your process management is already configured for it. Otherwise use ",[33,932,933],{},"systemctl restart yourapp",[198,935,937],{"id":936},"_14-add-a-visible-release-marker","14. Add a visible release marker",[14,939,940],{},"Expose a version value so you can verify the active release directly.",[14,942,943],{},"Example Flask route:",[26,945,949],{"className":946,"code":947,"language":948,"meta":31,"style":31},"language-python shiki shiki-themes github-light github-dark","from flask import Flask\nimport os\n\napp = Flask(__name__)\n\n@app.route(\"\u002Fversion\")\ndef version():\n    return {\n        \"release\": os.getenv(\"APP_RELEASE\", \"unknown\")\n    }\n","python",[33,950,951,965,972,976,992,996,1009,1020,1028,1047],{"__ignoreMap":31},[36,952,953,956,959,962],{"class":38,"line":39},[36,954,955],{"class":117},"from",[36,957,958],{"class":94}," flask ",[36,960,961],{"class":117},"import",[36,963,964],{"class":94}," Flask\n",[36,966,967,969],{"class":38,"line":53},[36,968,961],{"class":117},[36,970,971],{"class":94}," os\n",[36,973,974],{"class":38,"line":66},[36,975,508],{"emptyLinePlaceholder":507},[36,977,978,981,984,987,990],{"class":38,"line":83},[36,979,980],{"class":94},"app ",[36,982,983],{"class":117},"=",[36,985,986],{"class":94}," Flask(",[36,988,989],{"class":79},"__name__",[36,991,927],{"class":94},[36,993,994],{"class":38,"line":108},[36,995,508],{"emptyLinePlaceholder":507},[36,997,998,1001,1004,1007],{"class":38,"line":127},[36,999,1000],{"class":42},"@app.route",[36,1002,1003],{"class":94},"(",[36,1005,1006],{"class":46},"\"\u002Fversion\"",[36,1008,927],{"class":94},[36,1010,1011,1014,1017],{"class":38,"line":521},[36,1012,1013],{"class":117},"def",[36,1015,1016],{"class":42}," version",[36,1018,1019],{"class":94},"():\n",[36,1021,1022,1025],{"class":38,"line":527},[36,1023,1024],{"class":117},"    return",[36,1026,1027],{"class":94}," {\n",[36,1029,1030,1033,1036,1039,1042,1045],{"class":38,"line":533},[36,1031,1032],{"class":46},"        \"release\"",[36,1034,1035],{"class":94},": os.getenv(",[36,1037,1038],{"class":46},"\"APP_RELEASE\"",[36,1040,1041],{"class":94},", ",[36,1043,1044],{"class":46},"\"unknown\"",[36,1046,927],{"class":94},[36,1048,1049],{"class":38,"line":539},[36,1050,1051],{"class":94},"    }\n",[14,1053,1054],{},"Then verify production:",[26,1056,1058],{"className":28,"code":1057,"language":30,"meta":31,"style":31},"curl https:\u002F\u002Fyour-domain\u002Fversion\n",[33,1059,1060],{"__ignoreMap":31},[36,1061,1062,1064],{"class":38,"line":39},[36,1063,754],{"class":42},[36,1065,1066],{"class":46}," https:\u002F\u002Fyour-domain\u002Fversion\n",[14,1068,1069],{},"This is the fastest way to prove the new release is actually live.",[18,1071,1073],{"id":1072},"common-causes","Common Causes",[178,1075,1076,1083,1096,1105,1114,1123,1129,1137,1143,1152],{},[181,1077,1078,1082],{},[1079,1080,1081],"strong",{},"Gunicorn service was not restarted after deploy"," → workers continue serving code already loaded in memory → restart the systemd service or send a controlled Gunicorn reload.",[181,1084,1085,1091,1092,1095],{},[1079,1086,1087,1088,1090],{},"systemd unit points to an old ",[33,1089,467],{}," or virtualenv"," → service starts successfully but from the wrong release → update the unit file, run ",[33,1093,1094],{},"systemctl daemon-reload",", and restart.",[181,1097,1098,1101,1102,1104],{},[1079,1099,1100],{},"Symlink-based release did not switch to the latest release"," → active process still uses the previous target → update the ",[33,1103,618],{}," symlink and restart the service.",[181,1106,1107,1110,1111,1113],{},[1079,1108,1109],{},"Nginx still points to an old socket or upstream"," → requests go to the wrong backend process → correct ",[33,1112,680],{}," and reload Nginx.",[181,1115,1116,1119,1120,1122],{},[1079,1117,1118],{},"Environment variables changed but service was not restarted"," → new config is not loaded into the process → restart the service after updating ",[33,1121,477],{}," or drop-ins.",[181,1124,1125,1128],{},[1079,1126,1127],{},"Static files were changed but not rebuilt or refreshed"," → pages appear partially outdated → rebuild assets and verify the Nginx static root.",[181,1130,1131,1134,1135,397],{},[1079,1132,1133],{},"Browser, CDN, or reverse proxy cache serves old responses"," → code is updated but the client sees stale content → bypass or purge caches and test with ",[33,1136,754],{},[181,1138,1139,1142],{},[1079,1140,1141],{},"Docker container was not rebuilt or recreated"," → running image still contains old code → rebuild the image and redeploy the container.",[181,1144,1145,1148,1149,1151],{},[1079,1146,1147],{},"Deployment copied files to a different directory than the service uses"," → new code exists on disk but is never executed → align the deploy path with ",[33,1150,467],{}," or container mount path.",[181,1153,1154,1157],{},[1079,1155,1156],{},"Reload command targeted the wrong service name"," → deployment completed without affecting the live app → identify the actual service serving traffic and restart that unit.",[18,1159,1161],{"id":1160},"debugging-section","Debugging Section",[14,1163,1164],{},"Check service state:",[26,1166,1168],{"className":28,"code":1167,"language":30,"meta":31,"style":31},"sudo systemctl status yourapp --no-pager\nsudo journalctl -u yourapp -n 100 --no-pager\nsudo journalctl -u yourapp -f\n",[33,1169,1170,1182,1201],{"__ignoreMap":31},[36,1171,1172,1174,1176,1178,1180],{"class":38,"line":39},[36,1173,43],{"class":42},[36,1175,47],{"class":46},[36,1177,73],{"class":46},[36,1179,76],{"class":46},[36,1181,80],{"class":79},[36,1183,1184,1186,1189,1192,1194,1196,1199],{"class":38,"line":53},[36,1185,43],{"class":42},[36,1187,1188],{"class":46}," journalctl",[36,1190,1191],{"class":79}," -u",[36,1193,76],{"class":46},[36,1195,145],{"class":79},[36,1197,1198],{"class":79}," 100",[36,1200,80],{"class":79},[36,1202,1203,1205,1207,1209,1211],{"class":38,"line":66},[36,1204,43],{"class":42},[36,1206,1188],{"class":46},[36,1208,1191],{"class":79},[36,1210,76],{"class":46},[36,1212,1213],{"class":79}," -f\n",[14,1215,1216],{},"Inspect the rendered unit and environment:",[26,1218,1220],{"className":28,"code":1219,"language":30,"meta":31,"style":31},"sudo systemctl cat yourapp\nsudo systemctl show yourapp | grep -E 'Environment=|EnvironmentFiles='\n",[33,1221,1222,1232],{"__ignoreMap":31},[36,1223,1224,1226,1228,1230],{"class":38,"line":39},[36,1225,43],{"class":42},[36,1227,47],{"class":46},[36,1229,455],{"class":46},[36,1231,63],{"class":46},[36,1233,1234,1236,1238,1240,1242,1244,1246,1248],{"class":38,"line":53},[36,1235,43],{"class":42},[36,1237,47],{"class":46},[36,1239,589],{"class":46},[36,1241,76],{"class":46},[36,1243,118],{"class":117},[36,1245,121],{"class":42},[36,1247,598],{"class":79},[36,1249,601],{"class":46},[14,1251,1252],{},"Verify the running process path:",[26,1254,1256],{"className":28,"code":1255,"language":30,"meta":31,"style":31},"ps aux | grep gunicorn\nreadlink -f \u002Fproc\u002F$(pgrep -n -f 'gunicorn.*yourapp')\u002Fcwd\nls -l \u002Fproc\u002F$(pgrep -n -f 'gunicorn.*yourapp')\u002Fexe\n",[33,1257,1258,1270,1292],{"__ignoreMap":31},[36,1259,1260,1262,1264,1266,1268],{"class":38,"line":39},[36,1261,111],{"class":42},[36,1263,114],{"class":46},[36,1265,118],{"class":117},[36,1267,121],{"class":42},[36,1269,124],{"class":46},[36,1271,1272,1274,1276,1278,1280,1282,1284,1286,1288,1290],{"class":38,"line":53},[36,1273,130],{"class":42},[36,1275,133],{"class":79},[36,1277,136],{"class":46},[36,1279,139],{"class":94},[36,1281,142],{"class":42},[36,1283,145],{"class":79},[36,1285,133],{"class":79},[36,1287,150],{"class":46},[36,1289,153],{"class":94},[36,1291,156],{"class":46},[36,1293,1294,1296,1298,1300,1302,1304,1306,1308,1310,1312],{"class":38,"line":66},[36,1295,219],{"class":42},[36,1297,334],{"class":79},[36,1299,136],{"class":46},[36,1301,139],{"class":94},[36,1303,142],{"class":42},[36,1305,145],{"class":79},[36,1307,133],{"class":79},[36,1309,150],{"class":46},[36,1311,153],{"class":94},[36,1313,351],{"class":46},[14,1315,1316],{},"Check listening ports and sockets:",[26,1318,1320],{"className":28,"code":1319,"language":30,"meta":31,"style":31},"sudo ss -ltnp | grep gunicorn\nsudo ss -lxnp | grep gunicorn\n",[33,1321,1322,1338],{"__ignoreMap":31},[36,1323,1324,1326,1329,1332,1334,1336],{"class":38,"line":39},[36,1325,43],{"class":42},[36,1327,1328],{"class":46}," ss",[36,1330,1331],{"class":79}," -ltnp",[36,1333,118],{"class":117},[36,1335,121],{"class":42},[36,1337,124],{"class":46},[36,1339,1340,1342,1344,1347,1349,1351],{"class":38,"line":53},[36,1341,43],{"class":42},[36,1343,1328],{"class":46},[36,1345,1346],{"class":79}," -lxnp",[36,1348,118],{"class":117},[36,1350,121],{"class":42},[36,1352,124],{"class":46},[14,1354,1355],{},"Validate Nginx configuration:",[26,1357,1359],{"className":28,"code":1358,"language":30,"meta":31,"style":31},"sudo nginx -t\nsudo grep -R \"proxy_pass\\|root\\|alias\" \u002Fetc\u002Fnginx\u002Fsites-enabled \u002Fetc\u002Fnginx\u002Fconf.d\n",[33,1360,1361,1369],{"__ignoreMap":31},[36,1362,1363,1365,1367],{"class":38,"line":39},[36,1364,43],{"class":42},[36,1366,88],{"class":46},[36,1368,664],{"class":79},[36,1370,1371,1373,1375,1377,1379,1381],{"class":38,"line":53},[36,1372,43],{"class":42},[36,1374,121],{"class":46},[36,1376,706],{"class":79},[36,1378,709],{"class":46},[36,1380,712],{"class":46},[36,1382,715],{"class":46},[14,1384,1385],{},"Inspect release directories:",[26,1387,1388],{"className":28,"code":242,"language":30,"meta":31,"style":31},[33,1389,1390,1398],{"__ignoreMap":31},[36,1391,1392,1394,1396],{"class":38,"line":39},[36,1393,219],{"class":42},[36,1395,251],{"class":79},[36,1397,254],{"class":46},[36,1399,1400,1402,1404],{"class":38,"line":53},[36,1401,130],{"class":42},[36,1403,133],{"class":79},[36,1405,263],{"class":46},[14,1407,1408],{},"If using Docker:",[26,1410,1412],{"className":28,"code":1411,"language":30,"meta":31,"style":31},"docker ps\ndocker compose logs --tail=100\ndocker inspect \u003Ccontainer_name_or_id>\n",[33,1413,1414,1420,1430],{"__ignoreMap":31},[36,1415,1416,1418],{"class":38,"line":39},[36,1417,826],{"class":42},[36,1419,854],{"class":46},[36,1421,1422,1424,1426,1428],{"class":38,"line":53},[36,1423,826],{"class":42},[36,1425,829],{"class":46},[36,1427,863],{"class":46},[36,1429,866],{"class":79},[36,1431,1432,1434,1436,1438,1440,1442],{"class":38,"line":66},[36,1433,826],{"class":42},[36,1435,881],{"class":46},[36,1437,884],{"class":117},[36,1439,887],{"class":46},[36,1441,890],{"class":94},[36,1443,893],{"class":117},[14,1445,1446],{},"What to look for:",[178,1448,1449,1452,1455,1458,1461,1464],{},[181,1450,1451],{},"Gunicorn cwd points to the wrong release",[181,1453,1454],{},"systemd still references an old path",[181,1456,1457],{},"Nginx proxies to an outdated socket",[181,1459,1460],{},"static files on disk do not match what clients receive",[181,1462,1463],{},"container image or bind mount is stale",[181,1465,1466],{},"restart failed silently because the wrong service was targeted",[18,1468,1470],{"id":1469},"checklist","Checklist",[178,1472,1475,1484,1490,1504,1510,1516,1522,1528,1534],{"className":1473},[1474],"contains-task-list",[181,1476,1479,1483],{"className":1477},[1478],"task-list-item",[1480,1481],"input",{"disabled":507,"type":1482},"checkbox"," The latest code is present in the expected deployment directory.",[181,1485,1487,1489],{"className":1486},[1478],[1480,1488],{"disabled":507,"type":1482}," The running Gunicorn process points to the correct working directory.",[181,1491,1493,1495,1496,1041,1498,1500,1501,1503],{"className":1492},[1478],[1480,1494],{"disabled":507,"type":1482}," ",[33,1497,472],{},[33,1499,467],{},", and ",[33,1502,477],{}," paths are correct in systemd.",[181,1505,1507,1509],{"className":1506},[1478],[1480,1508],{"disabled":507,"type":1482}," The service was restarted or reloaded after deployment.",[181,1511,1513,1515],{"className":1512},[1478],[1480,1514],{"disabled":507,"type":1482}," Nginx configuration is valid and reloaded if upstream or static settings changed.",[181,1517,1519,1521],{"className":1518},[1478],[1480,1520],{"disabled":507,"type":1482}," Static assets were rebuilt or refreshed if needed.",[181,1523,1525,1527],{"className":1524},[1478],[1480,1526],{"disabled":507,"type":1482}," Browser, CDN, or proxy caching is not hiding the new release.",[181,1529,1531,1533],{"className":1530},[1478],[1480,1532],{"disabled":507,"type":1482}," If using Docker, the running container was rebuilt and recreated from the latest image.",[181,1535,1537,1539],{"className":1536},[1478],[1480,1538],{"disabled":507,"type":1482}," A live test confirms the expected version or code change is now served.",[18,1541,1543],{"id":1542},"related-guides","Related Guides",[178,1545,1546,1550,1554,1558],{},[181,1547,1548],{},[393,1549,770],{"href":769},[181,1551,1552],{},[393,1553,396],{"href":395},[181,1555,1556],{},[393,1557,608],{"href":607},[181,1559,1560],{},[393,1561,1563],{"href":1562},"\u002Fchecklist\u002Fflask-production-checklist-everything-you-must-do","Flask Production Checklist (Everything You Must Do)",[18,1565,1567],{"id":1566},"faq","FAQ",[198,1569,1571],{"id":1570},"why-is-my-flask-app-showing-old-code-after-deploy","Why is my Flask app showing old code after deploy?",[14,1573,1574],{},"The live Gunicorn process is usually still running the previous release, environment, or container image.",[198,1576,1578,1579,1582],{"id":1577},"should-i-use-gunicorn-reload-in-production","Should I use Gunicorn ",[33,1580,1581],{},"--reload"," in production?",[14,1584,1585],{},"No. Use a controlled restart or reload through systemd or your process manager.",[198,1587,1589],{"id":1588},"do-environment-variable-changes-require-a-restart","Do environment variable changes require a restart?",[14,1591,1592],{},"Yes. systemd-managed services must be restarted to load updated environment values.",[198,1594,1596],{"id":1595},"can-nginx-cause-this-problem","Can Nginx cause this problem?",[14,1598,1599],{},"Yes. If Nginx points to the wrong upstream or serves outdated static files, the app can appear unchanged.",[198,1601,1603],{"id":1602},"how-can-i-prove-the-new-release-is-live","How can I prove the new release is live?",[14,1605,1606,1607,1609],{},"Add a version endpoint or commit hash output and verify it with ",[33,1608,754],{}," against production.",[18,1611,1613],{"id":1612},"final-takeaway","Final Takeaway",[14,1615,1616],{},"If Flask is not showing deployed changes, the active serving process is usually still tied to the previous code, environment, container, or asset set. Verify the live process path, restart the correct service, reload Nginx only when needed, and confirm the running release with a direct version check.",[1618,1619,1620],"style",{},"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":31,"searchDepth":53,"depth":53,"links":1622},[1623,1624,1625,1641,1642,1643,1644,1645,1653],{"id":20,"depth":53,"text":21},{"id":169,"depth":53,"text":170},{"id":195,"depth":53,"text":196,"children":1626},[1627,1628,1629,1630,1631,1632,1633,1634,1635,1636,1637,1638,1639,1640],{"id":200,"depth":66,"text":201},{"id":269,"depth":66,"text":270},{"id":296,"depth":66,"text":297},{"id":357,"depth":66,"text":358},{"id":400,"depth":66,"text":401},{"id":437,"depth":66,"text":438},{"id":571,"depth":66,"text":572},{"id":611,"depth":66,"text":612},{"id":646,"depth":66,"text":647},{"id":718,"depth":66,"text":719},{"id":773,"depth":66,"text":774},{"id":812,"depth":66,"text":813},{"id":896,"depth":66,"text":897},{"id":936,"depth":66,"text":937},{"id":1072,"depth":53,"text":1073},{"id":1160,"depth":53,"text":1161},{"id":1469,"depth":53,"text":1470},{"id":1542,"depth":53,"text":1543},{"id":1566,"depth":53,"text":1567,"children":1646},[1647,1648,1650,1651,1652],{"id":1570,"depth":66,"text":1571},{"id":1577,"depth":66,"text":1649},"Should I use Gunicorn --reload in production?",{"id":1588,"depth":66,"text":1589},{"id":1595,"depth":66,"text":1596},{"id":1602,"depth":66,"text":1603},{"id":1612,"depth":53,"text":1613},"Complete guide on flask app not reloading after deploy for Flask production environments.","md",{"ogTitle":5,"ogDescription":1654,"twitterCard":1657,"robots":1658,"canonical":1659},"summary_large_image","index, follow","https:\u002F\u002Fflask-deployment.com\u002Ffix-issues\u002Fflask-app-not-reloading-after-deploy","\u002Ffix-issues\u002Fflask-app-not-reloading-after-deploy",{"title":5,"description":1654},"fix-issues\u002Fflask-app-not-reloading-after-deploy","lgc8eJzARTHcKeihzCXIS9c8o__7Ue-mVlRPMwa2x04",1776805765052]