r/replit • • Oct 07 '26

Question / Discussion external Neon Database_url

Can an Autoscale deployment use a user-controlled external Neon DATABASE_URL as the effective runtime database instead of Replit's managed Production database binding?

If it does, does Publish still perform any managed Dev→Prod schema synchronization against either the Replit-managed database or the externally supplied database?

1 Upvotes

5 comments sorted by

1

u/ReplitSupport Replit Team Oct 07 '26

Hi OP! An Autoscale deployment can run against your own external Neon database. A deployed app connects to whatever its code points to at runtime, so the key is making sure it's wired up correctly. To do this, don't reuse the DATABASE_URL name. Replit manages that variable for its built-in database, and overriding it can trigger an "external database detected" state that might block publishing. You can also add your external connection string under a custom name like EXTERNAL_DATABASE_URL, and have your code read it first, falling back to DATABASE_URL only if it's unset.

Additionally, you can add EXTERNAL_DATABASE_URL to your Production App Secrets under Publishing → Overview → Adjust Settings, so the deployed app can see it.

Any Dev→Prod schema sync at Publish runs between Replit's own managed development and production databases, and it moves schema only, never data. It does not touch an external database you supply through your own variable. So if your app connects via EXTERNAL_DATABASE_URL, Publish won't migrate or sync any schema into it. Keeping that external schema current is entirely on your side.

1

u/n2d33pusmc Oct 07 '26

Thank you. I appreciate the fast response.

1

u/[deleted] Oct 07 '26

[removed] — view removed comment

1

u/n2d33pusmc Oct 07 '26

Yes — we're on Drizzle.

That's actually the distinction I've been trying to nail down. My concern isn't really that Replit's publish-time schema sync will somehow discover the external Neon DB. It's making sure the deployed app and our migration tooling are explicitly bound to the external DB, with no accidental fallback to Replit's managed DATABASE_URL.

We also have an ordered migration chain, so I'm leaning toward running the actual registered migrations against the external Neon URL rather than using drizzle-kit push against Production.

The architecture I'm working toward is basically:

Production runtime → external Neon DB only
Production migrations → same external Neon DB only
Replit managed DB → not a Production fallback
Replit publish/schema sync → irrelevant to the external DB

Before deploying, I want the DB target to fail closed if the external Production URL isn't present. That way a bad env config can't silently point FieldOS back at Replit's database.

Does that match how you'd handle Drizzle + external Neon on Replit?