Server GTM Hosting has moved to its own platform.

Visit TagLinc(opens in a new tab)
Applications

Migrate a Next.js App and Its Postgres Database to FlyNode

Deploy an existing Next.js app from Git with a PostgreSQL created beside it, import your data and run your migrations.

5 min readUpdated Nov 2, 2026FlyNode docs
Browse documentation

Need a hand?

Can't find your answer? Our team replies fast.

Contact support

This guide moves an existing Next.js app that uses PostgreSQL to a FlyNode Cloud Workspace. The app runs as a Custom app built from your Git repository, and FlyNode creates the PostgreSQL next to it with DATABASE_URL already set.

How the pieces fit

  • Next.js app: one Custom app. FlyNode builds your repository and runs it as a single container with a generated address and automatic SSL.
  • PostgreSQL: a database FlyNode creates with the app. Only your own apps on FlyNode can reach it, and it does not count toward your workspace's app limit.

Before you start

  • Your code is in a repository on GitHub, GitLab or Bitbucket. For a private repository, read Deploy a Private Repository.
  • npm run build and npm start work on your own computer.
  • You know every environment variable the app reads: authentication secrets, API keys and your public site address.

The fast way: let Claude do it

If you use Claude, it can do the deploy for you. Connect it once with Deploy and Migrate with Claude or the CLI, then:

  1. Push your project to GitHub.
  2. Tell Claude: Deploy this Next.js app to FlyNode with PostgreSQL.
  3. Claude gives you a private link. Open it and paste your secrets there. They never go through the chat.
  4. Open the live address Claude gives you.

Prefer the terminal? In your project folder run:

flynode deploy --db postgresql

FlyNode sets DATABASE_URL for you, which is what Prisma and Drizzle read. Send your other variables with flynode env push.

Step 1: Check your Next.js setup

  • Scripts. FlyNode builds with npm run build and starts with npm start, which runs next start. It listens on PORT, which FlyNode sets to 3000, so you do not need to change anything.
  • Standalone output. If your next.config sets output: 'standalone', set the Start command in advanced build options to node .next/standalone/server.js.
  • Public variables. Variables that start with NEXT_PUBLIC_ are written into the build. Add them before the first build, or press Save and redeploy after adding them.
  • The database during the build. Pages that query Postgres while next build runs need DATABASE_URL at build time. When you pick the database in the deploy form it is already there. Otherwise render those pages on request.

Step 2: Deploy the app with its database

  1. Go to Deploy and choose Custom app.
  2. Enter an app name, choose Public repository or Private repository, paste the repository address and check the branch.
  3. In the Database section press Next.js with Prisma or Drizzle. It ticks PostgreSQL. Leave Advanced build options empty first, unless you use standalone output (step 1).
  4. Press Continue, keep the generated domain, press Continue again and then Deploy App.
The Custom app form with the Database section: presets for common stacks and a checkbox for each database

FlyNode creates the database first and sets DATABASE_URL (and DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME and DB_PASSWORD) before the app starts. You can see them, and the database's own login, on the app's Database tab.

The Add a database card on the Database tab, with MySQL and Redis already added

Step 3: Move your data

  1. On your own computer, take a dump of the old database: pg_dump --no-owner --no-acl -Fc -f app.dump "OLD_CONNECTION_STRING". A plain .sql or .sql.gz file works too.
  2. Open the app, go to Database, find the PostgreSQL card and press Choose a file under Import a dump. Pick the file. The limit is 500 MB.
  3. Tick Replace everything in the database first to make the new database match the dump exactly. The import runs as one transaction, so a file that fails leaves the database as it was.
  4. FlyNode loads the file in the background and shows the result under the button. Check a few row counts.

If you use Prisma or Drizzle you can also create the tables with their migration command and copy only the data. The card also has Download, and FlyNode backs the database up every night with the app. If your data is bigger than 500 MB, or you want to stay on a provider such as Neon or Supabase, pick No database and set DATABASE_URL yourself in the next step.

Step 4: Add your other variables

Open the app, go to Settings and then Variables. Add every other variable, then press Save and redeploy. Nothing takes effect until the app is deployed again.

The Variables card of a Next.js app with PostgreSQL: DATABASE_URL and the DB variables already set by FlyNode

Two variables people forget when they move a Next.js app: the public address your authentication library expects (for example NEXTAUTH_URL or AUTH_URL) and your own public site address. Set them to the new address. See Build Logs, Environment Variables and Rollback.

Run migrations

With Prisma, add a script to package.json such as "start:prod": "prisma migrate deploy && next start" and set the Start command to npm run start:prod, so pending migrations run each time the app starts. FlyNode's start command field takes plain words only, so the chained commands live in the script. Try it against a copy of the database first.

Step 5: Check that it works

  1. Settings, then Deploys shows the build as Succeeded. If it failed, press View log.
  2. The Logs tab shows the output of next start.
  3. Open the app's address, sign in and open a page that reads from Postgres.

Step 6: Use your own domain

Add your domain from the Custom Domain tab and follow Custom Domains for Your Apps. After it is live, update callback addresses for sign-in providers and webhooks so they point at the new domain.

If something goes wrong

  • The build is killed or runs out of memory. Next.js builds need a few hundred megabytes or more. A Cloud Workspace shares its RAM between all of its apps, so stop other apps while you build or choose a larger size. See Understanding Resource Allocation.
  • The build fails with a database error. A page is querying Postgres during the build. Check that DATABASE_URL is set, or render the page on request.
  • The app shows Running but the address does not open. Check the Logs tab. The app must listen on PORT.
  • The import says the database refused the file. Use a plain .sql file or a custom-format .dump made with pg_dump. A file made with another tool's format may not load.

Next steps

Still stuck?

Open a support ticket from your dashboard and include the container name.

Contact support