In Cloudflare Pages, what can you roll a production deployment back to, and what does a rollback leave unchanged?
answer
- earlier deployments are kept
- only successful production builds
- no rebuild happens
- the Git branch is untouched
basics
~20 sA Pages rollback instantly makes an earlier, successfully built production deployment live again; preview deployments are not valid targets. It changes which deployment production serves, not the Git branch, so the bad commit is still at the branch tip.
solid answer
~40 sPages keeps every deployment, so from the project's **Deployments** list you can pick any **production** deployment that **built successfully** and choose *Rollback to this deployment*. Production switches to it instantly because nothing is rebuilt: the old deployment's files are served as they were built, including anything the build baked in from build-time variables. Preview deployments are not valid targets, and after a rollback you can still move forward to a newer production deployment. What a rollback does not touch is the repository: the production branch still ends in the bad commit, so the next production build would ship it again. Revert or fix the commit in Git, or pause automatic production deployments in branch deployment controls while you work on it.
code
bash · 1 linenpx wrangler pages deployment list --project-name marketing-site --environment productiongo deeper
Recall that Pages keeps earlier deployments and that a rollback makes an earlier successful production deployment live again from the Deployments list.
Explain why the rollback is instant, why previews are not valid targets, and that rolling forward to a newer production deployment is still possible.
Show the incident sequence: roll back first, then revert or pause automatic production deployments so the next build does not ship the bad commit again.
Decide who may roll back and how the team stops automatic builds during an incident, and keep enough recent production deployments as targets.
## What a Pages rollback is In **Cloudflare Pages**, every successful build or upload creates a **deployment**: an immutable set of files reachable at its own `<hash>.<project>.pages.dev` URL. The project's **production** hostnames (`<project>.pages.dev` and any custom domains) serve one of those deployments at a time. A **rollback** simply points production back at an earlier deployment. To do it, open the project's **Deployments** tab, find the target in *All deployments*, open its actions menu and select *Rollback to this deployment*. After you confirm, production changes instantly. ## What is a valid target | Deployment | Valid rollback target? | |---|---| | An earlier production deployment that built successfully | Yes | | A production deployment newer than the one you rolled back to | Yes, you can roll forward again | | A production build that failed | No, a failed build never produced a deployment to serve | | Any preview deployment | No, previews are not valid targets | The last row surprises people who tested a fix on a preview and want to "promote" it. A rollback cannot do that; the fix reaches production through the production branch (a merge in a Git project, or a deploy with the production branch name in a Direct Upload project). ## Why it is instant A rollback does not run the build command again. The earlier deployment's files are still stored, so Pages only changes which deployment production serves. Two consequences follow: - the site comes back **exactly as it was built**, including any value the build inlined from build-time environment variables at that time; - the rollback cannot fail on a broken build environment, a missing dependency or a changed lockfile, which is exactly why it is the right first move in an incident. ## What a rollback leaves unchanged A rollback is a change to what production serves, nothing more: - **The Git branch.** The production branch still ends in the commit that caused the problem. The next production build is made from that branch tip, so it would ship the same change again. - **The project's settings.** Build command, output directory, branch controls and custom domains stay as they are. - **Other deployments.** Previews and their aliases are not affected. ## Working through an incident 1. Roll back to the last good production deployment from the dashboard. 2. If the project builds automatically from Git, either revert the bad commit on the production branch or turn off **automatic production branch deployments** in branch deployment controls, so an unrelated merge does not redeploy the bad change. 3. Fix the problem on a branch and check it on that branch's preview URL. 4. Merge, let a new production deployment build, and turn automatic production deployments back on if you paused them. ## Rollback versus redeploying an old commit Teams sometimes "roll back" by re-running a build of an older commit instead. That is a different operation: - a **rollback** serves the earlier deployment's files byte for byte, in seconds; - a **rebuild** of an old commit runs with the project's current build settings and environment variables, and resolves any dependency the lockfile does not pin, so it can produce a different site, or fail; - a rebuild also creates a new deployment, which then becomes the newest production deployment in the list. Use the rollback to stop the damage, and a rebuild only once you know what changed. ## Direct Upload projects A Direct Upload project has no Git builds; deployments arrive from `wrangler pages deploy` or the dashboard. A rollback works the same way, but the thing to fix afterwards is the pipeline's input: the next run that deploys with the production branch name replaces production again, with whatever files that run uploads. ## Finding deployments from the command line Wrangler can list a project's deployments, with their IDs, environments and URLs: ```bash npx wrangler pages deployment list --project-name marketing-site --environment production ``` The rollback itself is done from the Deployments list (or the Pages API); `wrangler rollback` is a Workers command that rolls back a Worker's version, not a Pages project. Wrangler can also remove old deployments with `wrangler pages deployment delete`, but the latest deployment of a branch cannot be deleted, and deleting a deployment that still has an alias needs `--force`. Deleting old production deployments also removes them as rollback targets, so keep the recent ones.
- A fix looks right on a Pages preview. Can you roll production back to that preview?No. Preview deployments are not valid rollback targets. The fix reaches production through the production branch: merge it in a Git project, or redeploy with the production branch name in a Direct Upload project. Rollback only moves production between earlier production deployments that built successfully.
- After a Pages rollback, what can put the bad change back into production?The next production build. The rollback did not change the repository, so the production branch still ends in the bad commit, and any build from it carries that change. Revert the commit, or pause automatic production branch deployments until the fix is merged.
- A rollback rebuilds the old commit, so it takes as long as a normal build.
- You can roll production back to any preview deployment.
- Rolling back also reverts the bad commit on the production branch.
- Once you roll back, newer deployments can no longer be restored.
- `wrangler rollback` rolls back a Pages project.