Neon CLI commands — connection-string
Use the Neon CLI to manage Neon directly from the terminal
Before you begin
- Before running the
connection-stringcommand, ensure that you have installed the Neon CLI. - If you have not authenticated with the neonctl auth command, running a Neon CLI command automatically launches the Neon CLI browser authentication process. Alternatively, you can specify a Neon API key using the
--api-keyoption when running a command. See Connect.
For information about connecting to Neon, see Connect from any application.
The connection string command
This command constructs a Postgres connection string for connecting to a database in your Neon project. You can construct a connection string for any database in any branch. The connection string includes the password for the specified role.
Usage
branch specifies the branch name or id. If a branch name or ID is ommited, the primary branch is used.
Options
In addition to the Neon CLI global options, the connect-string command supports these options:
| Option | Description | Type | Required |
|---|---|---|---|
| --project-id | Project ID | string | Only if your Neon account has more than one project |
| --role-name | Role name | string | Only if your branch has more than one role |
| --database-name | Database name | string | Only if your branch has more than one database |
| --pooled | Construct a pooled connection. The default is false. | boolean | |
| --prisma | Construct a connection string for use with Prisma. The default is false. | boolean |
Examples
-
Generate a basic connection string for the current project, branch, and database:
-
Generate a pooled connection string for the current project, branch, and database with the
--pooledoption. This option adds a-poolerflag to the host name which enables connection pooling for clients that use this connection string. -
Generate a connection string for use with Prisma for the current project, branch, and database. The
--prismaoptions addsconnect_timeout=30option to the connection string to ensure that connections from Prisma Client do not timeout.
Need help?
Join the Neon community forum to ask questions or see what others are doing with Neon. Neon Pro Plan users can open a support ticket from the console. For more detail, see Getting Support.
Last updated on