Undeploying¶
Undeploying removes a running application from your environment. It stops the containers, removes the platform router's routing, and deregisters DNS records. Registry data (builds, config, images) is preserved by default so you can redeploy later.
Command Flags¶
APP_NAME is a required positional argument.
| Flag | Short | Description |
|---|---|---|
--env |
-e |
Target environment (resolved from APPMECCA_ENV or the mecca.conf default when omitted) |
--branch |
-b |
Branch to undeploy (omit to resolve the app's live branch) |
--purge |
Also delete registry data (config, build and env-var records) | |
--force |
Skip confirmation prompt |
-b resolves automatically for a single-branch app
Omit -b and AppMecca resolves whichever branch is actually running — so a
dev-only app undeploys cleanly without you naming the branch. If the app is
running on multiple branches, -b becomes required.
Basic Undeploy¶
To undeploy a specific branch instead of main:
Expected output
AppMecca asks for confirmation before proceeding. Type y to confirm.
Undeploy is not instant
Like deployment, undeploy is pull-based. The CLI queues the request and agents execute it. It typically completes within 10-15 seconds.
What Gets Cleaned Up¶
When you undeploy an app, the following resources are removed:
| Resource | Cleaned Up |
|---|---|
| Running containers | Stopped and removed on every host |
| Router rules | Deleted (traffic stops routing to the app) |
| Routing groups | Deleted |
| DNS records | Deregistered |
| Port allocations | Released (ports become available for other apps) |
| Deploy record | Cleared from the registry |
| Config, build and env-var records | Preserved (use --purge to delete) |
After undeploy completes, the app's URL will stop working, but your build history and configuration are preserved for redeployment.
Images and data are not deleted
Undeploy does not delete your Docker images, your database, or your drive
contents. They remain available for future deployments. To fully purge an
app, use mecca app delete instead.
Redeploying After Undeploy¶
Since registry data is preserved by default, you can redeploy with a simple:
No need to re-register the app or trigger a new build.
Purge All Data¶
If you want to also delete all registry data (CONFIG, BUILD, ENV records), use --purge:
Expected output
With --purge, the following are also deleted:
- Registration record -- your app's registration and resolved
appmecca.yamlconfiguration - Build records -- history of all builds and their image tags
- Environment variables -- values set via
mecca var set
After a purge, you would need to re-register the app and trigger a new build before deploying again.
When to use --purge
Use --purge when you are permanently removing an app and don't plan to redeploy it. For temporary removal (maintenance, cost savings, etc.), omit --purge so you can easily redeploy later.
Skip Confirmation¶
To skip the confirmation prompt (useful in scripts or CI/CD pipelines):
You can combine flags:
Undeploy vs Unregister vs Apps Delete¶
These commands serve different purposes:
| Command | What It Does |
|---|---|
mecca app undeploy |
Stops the running deployment. Registry data preserved by default. Images and data remain. |
mecca app undeploy --purge |
Stops deployment and deletes registry data. Images and data remain. |
mecca app unregister |
Alias for app delete — a permanent purge. Not a registry-only removal. |
mecca app delete |
Full purge. Removes everything: images, build projects, secrets, logs, the database, and registry data. |
Use undeploy when you want to stop running the app but might redeploy it later — it stops the containers and leaves everything else intact. Use app delete when you want to completely remove all traces of the app from the environment. ⚠ app unregister is not a lighter middle option: it is an alias for app delete and destroys just as much.
Apps Unregister¶
⚠ unregister is an alias for app delete — a permanent purge. It is not a registry-only removal: the database is backed up and dropped, and images, build history, secrets and every platform resource belonging to the app are destroyed. To stop an app without destroying anything, use undeploy above.
Add --force to skip the confirmation prompt. After unregistering, you can re-register with mecca register.
Apps Delete¶
Fully purge an app and all its resources:
This removes the app's image repositories, build project, secrets, collected logs, object-storage data, its database (backed up first, then dropped), and all registry records. Add --force to skip confirmation and auto-undeploy if the app is currently running.
app delete drops your database
The tenant database is backed up and then dropped. Backup bundles taken
with mecca app backup survive, so take one first if the data matters.
Branch cleanup
To fully clean up a feature branch (including its database, backups, and registry records), use mecca app delete myapp -e dev -b feature/payments. See Branch Deployments for details.
How Undeploy Works Internally¶
The undeploy process follows the same pull-based model as deployment:
- You run
mecca app undeploy myapp -e devon your laptop - The CLI writes an
UNDEPLOY_REQUESTEDrow to the PostgreSQL deploy queue - The leader agent picks it up and executes the cleanup:
- Stops containers on its host
- Deletes the router rules and routing groups
- Deregisters the DNS records
- Clears deploy state from the registry (config, build and env-var records preserved unless
--purge)
- Follower agents stop their containers
- The status is updated to
UNDEPLOYED
Fault-tolerant cleanup
If any single cleanup step fails (for example, a routing group was already deleted), the undeploy continues with the remaining steps. Errors are logged but do not halt the process.
Verifying Undeploy Completed¶
After undeploying, check the app's state:
The app should no longer report running. To watch the undeploy action itself,
pass the action ID that mecca app undeploy printed:
You can also check that the URL is no longer accessible — take the exact hostname
from mecca app show, since it includes the service name and your group slug:
curl -s -o /dev/null -w "%{http_code}" https://myapp-web-yourgroup.dev.yourdomain.io
# Should return 503 or connection refused
Next Steps¶
- Rolling Back -- revert to a previous version instead of fully undeploying
- Deploying Your App -- redeploy after an undeploy
- Troubleshooting -- help with undeploy issues