Unable to get connection URI after creating branch from Neon CLI
I am running the following command to create a neon branch and execute a sql file against it. The SQL file simply creates a new test table
neonctl branches create --project-id xxxxxxxx --name $(git branch --show-current) --psql -- -f src/sql-commands/test.sql
I see the new Neon branch in the console, and also see the test table. However, the output from the terminal command is
ERROR: Branch br-restless-mouse-a56unmm9 doesn't have a connection uri
I need to get the connection URL though, for other commands. What can I do to get the connection URI?8 Replies
eastern-cyan•2y ago
You should be able to get it from the Connection Details widget in the Neon Console. You can also use the Neon CLI connect-string command.
https://neon.tech/docs/reference/cli-connection-string
Neon
Neon CLI commands — connection-string - Neon Docs
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 auto...
eastern-cyan•2y ago
That command will look like this:
neonctl connection-string <branch_name>
stormy-goldOP•2y ago
@Daniel basically, what I want to do is
1. create a new branch from main branch
2. connect to the new branch immediately to execute a sql file against it
3. automatically get the database uri of the new branch I just created, to pipe to a file
stormy-goldOP•2y ago
and am actually not getting the connection url from the output at all, even with a simple create branch command

eastern-cyan•2y ago
That's odd. I get the URI. What version of the Neon CLI are you running and what's your operating system? Maybe this is a bug.

eastern-cyan•2y ago
To connect to the new branch and run an sql file, you can use a command like this one. I specify the branch_id here, but you can also specify the branch name.
neonctl connection-string --project-id small-bush-58134374 br-quiet-leaf-a58lzl2x --psql -- -f dump.sql
stormy-goldOP•2y ago
the version is
"neonctl": "^1.29.3"eastern-cyan•2y ago
OK. You're at the latest, so the version is not the issue. What operating system are you running on? I'd like to try an reproduce the issue.