A practical checklist for leaving Heroku, Render or Railway
Leaving a hosted PaaS is less a leap than a sequence. The usual surprises are not "Docker is hard". They are an environment variable nobody listed, a release-phase migration that only the old platform ran, a Postgres add-on that was never dumped, or a DNS cut that happened before the new health check passed. You can move an app onto a server you own and keep the old side running until the new one…
Leaving a hosted PaaS like Heroku, Render, or Railway involves a systematic approach rather than a sudden leap. The main pitfalls to anticipate are often environment variables that were overlooked, release-phase migrations exclusive to the old platform, databases with add-ons that need to be manually detached, or DNS cutovers that precede the new platform's health check passing.
Transitioning an application to a server you control allows you to maintain the old system until the new one has demonstrated stability. The recommended sequence for a smooth migration includes:
1. Inventorying the platform's offerings: Make a detailed list of everything provided by the current platform beyond just the web process. This includes process types (web, workers, cron, scheduled jobs, etc.), the database used (Postgres, Redis, etc.), environment variables including secrets, domains and certificates, file storage, email services, background queues, and any other add-ons.
For Heroku, use commands like `heroku ps`, `heroku addons`, `heroku config`, and `heroku pg:info` to gather this information. Store this list securely, as it contains sensitive information. For Render or Railway, retrieve similar data from their respective dashboards or infrastructure files.
2. Securing a server to own: Choose a Linux Virtual Private Server (VPS) under your control. Ensure it has Docker Engine version 28 or newer running on a current version of Ubuntu, Debian, RHEL-family, Fedora, or Amazon Linux. The server will host both your application and its database. After migration, you should still be able to access these workloads even if the control plane you use later becomes unavailable.
Initially, do not point production DNS at this machine; instead, give it a testable hostname and open only ports 80 and 443, along with SSH access for initial setup.
3. Adapting the app for platform independence: A Dockerfile is the most portable unit for deployment. If you already have a Dockerfile, use it. If not, create one or utilize a builder to generate an image on your server. Pin the deployed image by its digest, not just its tag. Record the digest upon pulling or building the image to ensure a rollback is simply a redeployment of the same image, maintaining consistency.
Use `docker build` to create the image and `docker images --digests` to list images with their digests. Set a health check that the new server can run before directing traffic to it, such as an HTTP GET request to `/healthz` or a TCP check if no other health indicators are available.
4. Migrating configuration and data: Transfer non-secret variables to the new service. Securely store secrets, avoiding them in shell history or plaintext control planes. Copy the database from the old platform to a new Postgres instance on the server. Take a fresh dump of the current primary database, restore it to the new server's database, and compare the two to ensure data integrity.
Keep the old database operational until you confirm the new setup is working correctly. Common steps include using `pg_dump` to create a dump on the source and `pg_restore` to restore it on the target server.
5. Verifying the new setup: Before cutting DNS, confirm the new server is functioning properly. Deploy the image on the new server, run any necessary migrations from that image, and start the application. Test the health check on the new hostname and navigate through the application using real user actions like signing in, creating content, and executing background jobs if applicable.
Only after these checks should you attach the domain to the new servers. Keep the old platform running in parallel to allow for immediate traffic redirection if needed. Once you're confident, point your production DNS records at the new servers, monitor traffic and health checks, and review logs before decommissioning the old setup.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to
More from Dev.to on urgent.news
Report a problem with this story
Get the day's news by email. Daily, weekly or monthly. Sign up