🇦🇺 Hello Australia! Sydney region is officially live on Neon.Sign Up
Reference/Neon CLI

Neon CLI commands — connection-string

Use the Neon CLI to manage Neon directly from the terminal

Before you begin

  • Before running the connection-string command, 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-key option when running a command. See Connect.

For information about connecting to Neon, see Connect from any application.

The connection-string command

This command gets 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.


neonctl connection-string [branch] [options]

branch specifies the branch name or id. If a branch name or ID is ommited, the primary branch is used.


In addition to the Neon CLI global options, the connection-string command supports these options:

--context-fileContext file path and file namestring
--project-idProject IDstringOnly if your Neon account has more than one project
--role-nameRole namestringOnly if your branch has more than one role
--database-nameDatabase namestringOnly if your branch has more than one database
--pooledConstruct a pooled connection. The default is false.boolean
--prismaConstruct a connection string for use with Prisma. The default is false.boolean
--endpoint-typeThe compute endpoint type. The default is read-write. The choise are read_only and `read_write``string
--extendedShow extended information. The default is false.boolean
--psqlConnect to a database via psql using connection string. psql must be installed to use this option.boolean


  • Get a basic connection string for the current project, branch, and database:

    neonctl connection-string mybranch
  • Get a pooled connection string for the current project, branch, and database with the --pooled option. This option adds a -pooler flag to the host name which enables connection pooling for clients that use this connection string.

    neonctl connection-string --pooled
  • Get a connection string for use with Prisma for the current project, branch, and database. The --prisma options adds connect_timeout=30 option to the connection string to ensure that connections from Prisma Client do not timeout.

    neonctl connection-string --prisma
  • Get a connection string and connect with psql.

    neonctl connection-string --psql
  • Get a connection string, connect with psql, and run an .sql file.

    neonctl connection-string --psql -- -f dump.sql
  • Get a connection string, connect with psql, and run a query.

    neonctl connection-string --psql -- -c "SELECT version()"

Need help?

Join our Discord Server to ask questions or see what others are doing with Neon. Users on paid plans can open a support ticket from the console. For more detail, see Getting Support.

Last updated on

Edit this page
Was this page helpful?