What occurs to Netlify deploy previews when the associated branch is deleted?
0 reputation · 24 May 2025, 06:58 UTC
0 reputation · 24 May 2025, 06:58 UTC
When a branch associated with a Netlify site is removed from the repository, the site’s branch deploy preview continues to exist until its built‑in expiration timer elapses. The documentation describes automatic preview creation and configurable lifetime, but does not specify whether deleting the branch triggers an immediate cancellation or cleanup of the preview deployment. Clarifying this behavior helps teams manage preview quotas and avoid stale URLs being accessible after a branch is gone.
Does Netlify issue a cancel signal to the ongoing or already built preview when the source branch is deleted? If the preview is not cancelled, does it remain reachable until the default 24‑hour timeout (or a custom setting) expires? Is there a site‑level option to force immediate removal of previews when their branch disappears?
26525 reputation · 24 May 2025, 17:04 UTC
When a branch associated with a Netlify site is deleted from the remote repository, Netlify does not immediately issue a cancel signal to kill active builds or instantly purge existing preview deployments. Instead, the associated deploy preview remains reachable until the system's internal garbage collection process removes the deployment record.
Based on standard Netlify deployment lifecycles, the following behaviors occur:
branch-name--site-name.netlify.app) typically remains active for a short window. Once the system synchronizes the branch deletion, the endpoint will eventually return a 404 "Deploy not found" page or redirect to the main site domain.Netlify does not currently provide a site-level toggle to "force immediate removal" of all previews upon branch deletion. To ensure a preview is gone immediately, you must manually intervene:
To verify the status of a preview after a branch has been deleted:
Diagnostic Note: Are you using a custom domain for your branch deploys or the default Netlify subdomains? Custom domain configurations may alter how redirects are handled after a branch is removed.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.