How to Rollback Deployment on Firebase Hosting Quickly
To rollback a Firebase Hosting deployment, use the
firebase hosting:rollback command followed by the site name and the version number you want to restore. This command reverts your live site to a previous deployed version easily and safely.Syntax
The rollback command uses this pattern:
firebase hosting:rollback [options]--site <site-name>: Specify your Firebase Hosting site if you have multiple sites.--version <version-id>: The version ID to rollback to, which you get from your deployment history.
bash
firebase hosting:rollback --site your-site-name --version VERSION_ID
Example
This example shows how to rollback to a previous version of your Firebase Hosting site named my-cool-site. First, find the version ID from your deployment history, then run the rollback command.
bash
firebase hosting:rollback --site my-cool-site --version 1a2b3c4d5eOutput
ā Hosting site my-cool-site has been rolled back to version 1a2b3c4d5e
ā Deployment complete
Common Pitfalls
Common mistakes when rolling back Firebase Hosting include:
- Not specifying the
--siteoption when you have multiple sites, causing rollback to fail. - Using an incorrect or non-existent
version-id, which results in an error. - Trying to rollback without being logged in or without proper Firebase CLI setup.
Always check your deployment history with firebase hosting:versions:list --site your-site-name to get valid version IDs.
bash
firebase hosting:rollback --version wrong-version-id # This will fail because the version ID is invalid # Correct way: firebase hosting:rollback --site my-cool-site --version valid-version-id
Output
Error: Version 'wrong-version-id' not found.
ā Hosting site my-cool-site has been rolled back to version valid-version-id
ā Deployment complete
Quick Reference
| Command | Description |
|---|---|
| firebase hosting:rollback --site | Rollback to a specific deployed version |
| firebase hosting:versions:list --site | List all deployed versions for your site |
| firebase login | Login to Firebase CLI if not already logged in |
| firebase deploy | Deploy new changes to Firebase Hosting |
Key Takeaways
Use
firebase hosting:rollback with the correct site and version to revert your site.Always list versions with
firebase hosting:versions:list to find valid version IDs.Specify the
--site option if you manage multiple Firebase Hosting sites.Ensure you are logged in to Firebase CLI before running rollback commands.
Rollback does not delete versions; it simply makes a previous version live again.