Database migrations
Run schema migrations without routing through PgBouncer.
Neon · Const
DATABASE_URL_UNPOOLED is Neon’s direct PostgreSQL connection string. Use it for migrations and other operations that require a non-pooled connection.
Neon exposes the direct database connection string through the DATABASE_URL_UNPOOLED environment variable. Use it when a workload needs a non-pooled Postgres connection, such as migrations, LISTEN/NOTIFY, or transactions involving multiple round trips.
DATABASE_URL_UNPOOLED=<direct PostgreSQL connection string>A direct PostgreSQL connection string supplied through the DATABASE_URL_UNPOOLED environment variable.
DATABASE_URL_UNPOOLED contains Neon’s direct, non-pooled PostgreSQL connection string.LISTEN/NOTIFY, and transactions that require multiple round trips.const connectionString = process.env.DATABASE_URL_UNPOOLED;
if (!connectionString) throw new Error("DATABASE_URL_UNPOOLED is required");
console.log(connectionString);Reads Neon’s injected direct connection string, which can be passed to a Postgres driver or migration tool.
Run schema migrations without routing through PgBouncer.
Use PostgreSQL session features such as LISTEN/NOTIFY.
Execute transactions that require several database round trips.
DATABASE_URL_UNPOOLED represent?DATABASE_URL_UNPOOLED is Neon’s injected environment variable for the direct Postgres connection string. It is intended for operations that need a non-pooled connection, including migrations and session-oriented features.
Follow-up: When should the pooled variable be preferred? Use the pooled connection for ordinary application traffic when supporting a higher number of concurrent connections is the priority.
Use the direct connection for migrations because pooled connections can cause migration errors. The direct connection avoids routing migration traffic through the connection pool.
Follow-up: What other operations are listed for the direct variable? Neon also names LISTEN/NOTIFY and multi-round-trip transactions.
The direct connection is not the same as a Data API endpoint: it is a PostgreSQL connection string exposed as an environment variable. Code should read it and pass it to a PostgreSQL driver or compatible tool.
Follow-up: What protocol does the Data API use instead? It is accessed through HTTP and secured with JWT authentication and Row-Level Security.
DATABASE_URLDATABASE_URL_POOLEDDATABASE_URL_UNPOOLEDLISTEN/NOTIFY