---
title: Deploy an existing Next.js server
description: Build an existing Next.js app, deploy it as a Turn Zero Cloud server, and check its pages and files in development.
slug: /guides/deploy-an-existing-nextjs-server
order: 64
visibility: public
redirects_from: [/guides/deploy-an-existing-next-js-server]
---

# Deploy an existing Next.js server

Use this path for an existing Next.js 16 app that serves pages or routes at request time. It uses `next start` and the standard `.next/` build. For an app you already export as static files, follow [Publish a static site](/cloud/guides/publish-a-static-site/).

## Steps

### 1. Prepare the server

Open the app folder with its `package.json` and lockfile. Use [Node.js 24 and npm](/cloud/getting-started/prerequisites/) and an [AI coding agent connected to Turn Zero Cloud](/cloud/getting-started/connect-your-tool/). Keep `next`, `react` and `react-dom` in `dependencies`, where the Cloud image build can install them.

Use `next build` as your build script and `next start` as your `start` script. Keep the other scripts your project uses. Turn Zero sets `PORT` for the running server, and `next start` reads it. Leave a fixed `--port` out of the start script. See the [Next.js start command](https://nextjs.org/docs/app/api-reference/cli/next#next-start-options).

Create or reuse a [server application](/cloud/getting-started/deploy-an-application/#1-create-the-application). If it has no development environment, get the owner's agreement before you [turn on development](/cloud/guides/turn-on-development-and-promote/#turn-the-development-environment-on). Choose its audience and [submit the manifest](/cloud/getting-started/deploy-an-application/#2-declare-the-manifest). Name a health path that returns 200 when the app is ready.

If your app has no health path, you can add `/health`. For an App Router project with routes under `app/`, save this in `app/health/route.js`. Use the same location under `src/app/` if that is where the project keeps its routes.

```js
export const dynamic = 'force-dynamic';

export function GET() {
  return new Response('ok', { status: 200, headers: { 'content-type': 'text/plain' } });
}
```

Set `health` to `/health` in the manifest. If your app needs a database or another service before it can serve a request, make the health route check that service. See [The deploy health check](/cloud/concepts/the-deploy-health-check/).

### 2. Build and check the files

Install from your lockfile and run `npm run build` from the app folder. Turn Zero installs runtime dependencies for the server. Build the app on your computer before uploading it.

Keep `.next/` with its server output and `.next/static/`. Keep `public/` if you use it and any Next.js configuration the server reads. Leave those files in their original folders so `next start` can serve them.

This example uses the `turnzero` command to build the ZIP. Add this line to the root `.deployignore` to leave out the build cache.

```text
/.next/cache/
```

Run `turnzero hash --list` in the folder you will deploy. Check that the list includes the root `package.json`, lockfile, `manifest.json`, `.next/` output and any files in `public/` the app serves. Check that it leaves out the build cache, `node_modules` and any file with secret values. See [What the deploy ZIP holds](/cloud/concepts/what-the-deploy-zip-holds/).

### 3. Deploy and check development

Follow [Build and upload the artifact](/cloud/getting-started/deploy-an-application/#3-build-and-upload-the-artifact). [Read the status](/cloud/getting-started/deploy-an-application/#5-read-the-status) until the deploy finishes. If it succeeds, confirm that the intended version serves at the development hostname. If Cloud's image build fails, read the failed step and its build output. If the ZIP is missing files, check `turnzero hash --list`, fix the contents, then build and deploy again.

At the development hostname, open a page that renders on the server for each request, then check one app route. Confirm the health path returns 200 and the page's script and stylesheet under `/_next/static/` load. If your app has a file in `public/`, open its URL. Check the server logs if a request fails.

A Next.js 16 trial on Node.js 24 passed these checks. Its small app uploaded a 1.3 MB ZIP after excluding `.next/cache/`. Your upload depends on your build and files.

### Check other features your app uses

The trial covered the standard `next start` build and the checks above. In development, check the features you rely on before you ask the owner to [promote the tested version](/cloud/guides/turn-on-development-and-promote/#promote-to-production).

- **Image optimization.** Load an image through the optimizer and confirm it renders.
- **Page regeneration.** Change test data and check that the page updates when you expect it to.
- **Streamed responses.** Check through the development hostname that the first part arrives before the response finishes.
- **Local cache.** Restart the development app and check that it works with an empty cache. Files the running copy writes are lost when it is replaced.
- **Standalone output.** Test its start command and confirm its server files, static assets and public files are all present. See [Next.js standalone output](https://nextjs.org/docs/app/api-reference/config/next-config-js/output#automatically-copying-traced-files).
- **Public values in the browser.** Next.js puts `NEXT_PUBLIC_*` values into the browser files during `next build`. Check those values in the build you plan to promote and rebuild if they need to change. See [Next.js environment variables](https://nextjs.org/docs/app/guides/self-hosting#environment-variables).

## Expected result

The development hostname serves the intended version. The health path returns 200, an app route responds, and the server-rendered page loads its scripts and styles. Any files the app uses from `public/` load at their URLs.

## Refusals

See [Deploy from your computer](/cloud/getting-started/deploy-an-application/#refusals) for other deployment refusals.

| Refusal | Status | Cause | Remedy |
| --- | --- | --- | --- |
| `manifest_invalid` | 400 | The manifest breaks a rule. | Read `violations`, fix the named fields, and submit the whole manifest again. |
| `setting_secret_missing` | 409 | A setting names a secret that has no stored value for development. | Follow the `next` call in the response to store the value for the application and development, then deploy again. |
| `health_gate_failed` | 502 | The new server failed its health check. The deploy record marks the attempt as failed. | Read [the evidence from the failed check](/cloud/concepts/the-deploy-health-check/#the-evidence-a-failed-check-keeps). Fix the start command, health route or service it needs, then build and deploy again. |

## Related

- [Bring an existing application](/cloud/guides/bring-an-existing-application/)
- [Deploy from your computer](/cloud/getting-started/deploy-an-application/)
- [Test in development, then promote](/cloud/guides/turn-on-development-and-promote/)
