Last updated March 09, 2020
If you need to temporarily disable access to your Heroku app (for example, to perform a large migration), you can enable Heroku’s built-in maintenance mode. While in maintenance mode, your app serves a static maintenance page to all visitors.
While maintenance mode is active, the error code H80 is returned in your logs.
Scheduler jobs can still run while your app is in maintenance mode. Be mindful if you have any jobs set to run.
To enable maintenance mode:
$ heroku maintenance:on Enabling maintenance mode for myapp... done
To disable maintenance mode:
$ heroku maintenance:off Disabling maintenance mode for myapp... done
To check the current maintenance status of an app:
$ heroku maintenance off
Maintenance mode and dynos
Enabling or disabling maintenance mode does not alter your app’s dyno formation. Dynos continue to accrue billing hours while in maintenance mode. Web dynos continue to run, but Heroku’s routers block all incoming HTTP requests to them. Dynos of other types (such as worker dynos) also continue to run, and you can run one-off dynos as usual.
Scaling dynos in maintenance mode
It can be useful to scale your app’s dynos to zero during maintenance operations. For example, doing so can prevent database transactions from taking place.
You can enter maintenance mode and scale your
web dynos to zero like so:
$ heroku maintenance:on Enabling maintenance mode for myapp... done $ heroku ps:scale web=0 Scaling web processes... done, now running 0
You can do the same for your app’s other process types, such as
If you scale down dynos while in maintenance mode, make sure to scale them back up before restoring traffic to your app!
If you scale your app’s web dynos to zero, maintenance mode’s behavior differs depending on whether your app runs in the Common Runtime or in a Private Space:
- In the Common Runtime, your maintenance page continues to be served, because it is served by a shared routing cluster.
- In a Private Space, the maintenance page is not served, because it is served by a routing proxy that resides on the same compute instances as your web dynos.
Customizing your maintenance page
You can specify a custom maintenance page for your app by setting the following config var:
heroku config:set MAINTENANCE_PAGE_URL=//s3.amazonaws.com/<your_bucket>/your_maintenance_page.html
Please see this article for more information.