Deployment

Replit deployment build failed: how to read the logs and fix it

Short answer

  • Open Publishing → History, select the failed deployment and find the first line marked ERROR or FAILED. Later lines are usually side effects.
  • Most build failures come from missing dependencies, a wrong build or run command, type errors, or a failed database migration.
  • Autoscale and Reserved VM apps are limited to 8 GB, Static to 1 GB. Remove large files and generated output.

The publish button spins, then fails with a wall of red log text. Or it hangs at Building forever. A build failure feels scary, but the log almost always names the cause near the top. The trick is to find the first real error and ignore the dozens of lines that follow from it.

Symptoms

  • Publishing stops at the build step with Build failed.
  • The log shows Cannot find module, npm ERR!, error TS… or exit code 1.
  • No run command configured even though you set one.
  • Image size exceeds the 8 GiB limit.
  • The deployment is stuck in building or migration for a long time.

Likely causes

  1. A dependency is installed in the workspace but missing from package.json or requirements.txt/pyproject.toml.
  2. TypeScript or lint errors fail the production build, even though the dev server ignores them.
  3. The build command or output folder does not match the project.
  4. A database migration in the build step fails.
  5. Large files (datasets, videos, model weights, node_modules copies, build output) push the app over the size limit.

Step-by-step fix

1. Find the first error

Open Publishing → History, select the failed deployment and open its build log. Scroll to the first ERROR or FAILED line. Copy that line and the ten lines above it. That is what you give Agent, not the whole log.

2. Reproduce the build in the Shell

Run the same build command in the workspace Shell (for example npm ci && npm run build). If it fails there too, you can fix it with fast feedback instead of publishing again and again.

3. Fix dependencies and type errors

Add missing packages properly (npm install package-name so it lands in package.json). Fix TypeScript errors rather than disabling checks across the whole project. If the lockfile is out of sync, regenerate it.

4. Reset a stuck run command

Replit's help center gives a specific fix for No run command configured: in the deployment settings, disconnect the run command, add it back, save and publish again.

5. Get under the size limit

Find what is large with du -sh * .[^.]* | sort -h in the Shell. Move datasets and media to App Storage, delete generated folders, and keep build output out of the project. Before deleting anything, take a checkpoint or remix the app so you can go back.

6. Unstick a hung deployment

Open the command palette (Cmd+K or Ctrl+K), run Restart compute, then publish again. If it keeps hanging, contact Replit support with the full build log.

Copy-paste prompt for Replit Agent

Open a new Agent chat (a fresh chat keeps old attempts out of its context) and paste this:

My Replit deployment fails during the build. Here is the first error from Publishing > History and the lines above it:
[paste ~10-20 lines]
Please:
1. Explain the root cause in one sentence.
2. Reproduce the build in the Shell with the same build command the deployment uses, and fix the cause (add missing dependencies to package.json, fix type errors, correct the build output path).
3. Do not disable type checking or delete features to make the build pass.
4. If the app is close to the 8 GB limit, list the largest folders and propose what can move to App Storage or be removed. Do not delete anything without asking me.
Run the build again and show me it passes before I publish.

How to verify the fix

  • The build command passes in the Shell with no errors.
  • Publishing completes and the new deployment appears as live in History.
  • The live app shows the change you just made.

If the build passes but the app fails at the promote step, the cause is elsewhere: see port and 0.0.0.0 errors. If Agent keeps reintroducing errors, read how to stop the fix loop.

FAQ

Why does my app build in the workspace but not when publishing?

The workspace may have packages installed by hand or a dev server that tolerates type errors. The deployment runs a clean install and the production build, so anything not declared in your dependency files or any type error shows up there.

What is the size limit for Replit deployments?

Replit's docs state that Reserved VM and Autoscale deployments support apps up to 8 GB and Static deployments up to 1 GB.

Should I accept Replit's suggested fixes when the image is too large?

Take a checkpoint or remix the app first. Then review each suggestion so you only remove files you do not need.

Get a free audit