How Do I Make Sure My App Restarts Itself if It Crashes?
6 min read
If your app crashes at 3am, does it come back on its own? On a serverless host
(Vercel, Netlify, Cloudflare, most Lovable/Bolt/v0 deployments) yes, essentially
instantly, because there is no long-running process to stay dead. On a plain
server you rented and ran npm start on, no. It stays down until you log in and
restart it. Which world you are in is decided entirely by where you deployed,
and most vibe-coded founders never got told which one they picked.
Why this happens
There are two very different ways an app "runs," and they fail differently.
Serverless / managed platforms don't keep your app running between requests. Each request spins up a fresh instance, handles it, and goes away. A crash only kills that one request. The next visitor gets a brand new instance. There is nothing to restart because nothing was left running. This is the default for Vercel, Netlify, Cloudflare Workers, and the one-click deploys most AI builders give you.
A long-running server is the opposite. You have a single Node process
sitting on a machine, holding the app in memory. If that process throws an
unhandled error and exits, the machine is now running nothing. It will sit dead
forever, because nothing is watching it. Your agent wrote node server.js or
npm start in a setup guide, it worked when you ran it, and neither of you
asked "what restarts this when it dies." That is the gap.
How to check
- Find out where you deployed. If you clicked "Deploy" inside Lovable,
Bolt, v0, or Replit, or pushed to Vercel/Netlify, you are almost certainly
serverless and mostly covered. If you SSH into a server, or you rented a
"VPS" or a droplet and typed
npm start, you are running a bare process. - On a bare server, test it honestly. SSH in and kill the app:
pkill -f node(or Ctrl-C the terminal it is running in). Reload your site. If it is down and stays down, you have your answer: nothing brings it back. - Check whether anything is supervising the process. Run
systemctl status your-apporpm2 list. "Unit not found" or "command not found" means no supervisor is running, so a crash is permanent until you intervene.
The fix
If you are on a bare server, put a supervisor in front of the process so a crash triggers an automatic restart:
- Install a process manager. The simplest is PM2:
npm install -g pm2, thenpm2 start npm --name myapp -- start. - Make it survive a full machine reboot, not just a crash:
pm2 startup(run the command it prints), thenpm2 save. Now if the whole server power-cycles, your app comes back on boot. - Confirm it works. Kill the app again with
pkill -f nodeand watch:pm2 logsshould show it restarting within a second or two. A production-grade alternative is asystemdservice withRestart=always.
If you are serverless, you are already covered for process crashes, but note the honest limit below.
The trap to avoid
Do not assume "it restarts" means "it is fine." Auto-restart hides repeating crashes. If your app crashes on every request because of a bad database URL or a missing environment variable, a supervisor will restart it into the same crash, forever, and serverless will spin up fresh instances that all fail identically. The visitor still sees an error every time. Restart is a safety net for occasional failures, not a fix for a broken build. You still need to know a crash loop is happening, which means error tracking and logs, not just a restart policy.
Where this fits
"Does it come back up" is one of the first real-world questions between your demo and paying users, and it usually has an embarrassing answer nobody checked. The free Readiness Report works out where you are actually hosted and tells you whether an overnight crash means five seconds of downtime or a dead app until morning. Pair it with knowing when your app is broken for real users and whether you need a health-check endpoint, and if you would rather have the supervisor, boot-persistence, and crash-loop alerting set up for you in order, that is what the Finishing Pass is for.