My app works locally but not when I deploy it. Why?
The short answer
Almost always it's one of a short list: a missing environment variable, an address that still says localhost, a database that only exists on your computer, the wrong port, or a build that differs from the dev server. Read the build log and the app's output, match the error to the list below, and give Claude the exact message.
“It works on my machine” is the most common problem with AI-built apps, and it’s rarely mysterious. Your laptop quietly provides things a host doesn’t: your keys, your database, your files and a forgiving dev server.
First, find the real error
- Build log. Did the build finish? If not, the last lines say why.
- App output. Did the app start? Crashes on start usually name a missing variable or module.
- Browser console. For blank pages, press F12 and read the first red error.
Copy the exact message and give it to Claude with: “This works locally but fails when deployed. Here’s the error. What’s different online?”
The ten usual causes
1. A missing environment variable
Your .env file isn’t uploaded (and shouldn’t be). Every key in it must be set on the host. Ask Claude to list every variable the app reads.
2. An address that still says localhost
The front end calls http://localhost:3000/api, which means the visitor’s own computer. Use a relative path such as /api, or an environment variable for the API address.
3. A database that only exists on your computer
A SQLite file or a local Postgres doesn’t come along. Use a hosted database and read its address from DATABASE_URL. See putting an app online with a database.
4. The wrong port or address
Hosts tell your app which port to use. Listen on process.env.PORT (or $PORT in Python) and on 0.0.0.0, not a fixed 3000 on localhost.
5. Running the dev server instead of a build
npm run dev isn’t meant for production. The host should run the build command, then the start command.
6. Build-time variables missing during the build
In Vite apps, variables starting with VITE_ are baked in when the app is built. Setting them after the build changes nothing: set them, then deploy again.
7. Letter case in file names
macOS ignores case in file names and most hosts don’t. import "./Header" fails online if the file is header.tsx.
8. A package that’s missing from package.json
It’s installed on your computer but not listed, or it’s listed as a dev dependency and the host skips those. Ask Claude to check every import has a matching dependency.
9. Page routes that return 404 on refresh
Single-page apps route in the browser. The host must send index.html for page paths it doesn’t recognise.
10. Files written to disk
Uploads saved to a local folder vanish on many hosts after a restart. Store files in object storage or the database instead.
How Rehome helps
Rehome handles several of these before you see them:
- It runs the production build and start commands for your stack, gives the app its port, and checks that it starts before the address goes live.
- If your code uses a database, Rehome creates Postgres and sets
DATABASE_URL. - Missing keys get a secure link with the names filled in, so nothing is forgotten and nothing is pasted in the chat.
- When something still fails, Claude reads the build log and the app’s output with the
logstool and explains the problem in plain English.
For the whole process from the start, see how to host the app Claude Code built.
Questions
Where do I find the error when my deployed app breaks?
Look in two places: the build log (did it build?) and the app's output or runtime log (did it start, and what failed on the request?). The browser's developer console shows front-end errors. With Rehome, ask Claude to check the logs: the logs tool returns both.
Why does my app show a blank page after I deploy it?
Usually the front end can't reach its API (the address still points at localhost), a build-time environment variable is missing, or the files are served from the wrong path. Open the browser console: the first red error names the cause.
Why do I get a 404 when I refresh a page?
Your app routes pages in the browser, but the host looks for a file at that path. Tell the host to send index.html for unknown page routes.