---
layout: docs
page_title: connect postgres - Command
description: |-
  The "connect postgres" command performs a target authorization or consumes an existing authorization token, and launches a proxied postgres connection.
---

# connect postgres

Command: `boundary connect postgres`

The `connect postgres` command authorizes a session against a target and invokes a Postgres client for the connection.
The command fills in the local address and port.

@include 'cmd-connect-env-vars.mdx'


## Examples

The following example shows how to connect to a target with the ID `ttcp_eTcMueUYv` using a Postgres helper:

```shell-session
$ boundary connect postgres -target-id=ttcp_eTcZMueUYv \
   -dbname=northwind \
   -username=superuser \
   -format=table
```

When prompted, you must enter the password for the user, "superuser":

<CodeBlockConfig hideClipboard>

```plaintext
Password for user superuser:
psql (14.2, server 13.2 (Debian 13.2-1.pgdg100+1))
Type "help" for help.

postgres=#
```

</CodeBlockConfig>

## Usage

<CodeBlockConfig hideClipboard>

```shell-session
$ boundary connect postgres [options] [args]
```

</CodeBlockConfig>

@include 'cmd-connect-command-options.mdx'

### Postgres options:

- `-dbname` `(string: "")` - The database name you want to pass through to the client.
You can also specify the database name using the **BOUNDARY_CONNECT_DBNAME** environment variable.

- `-style`  `(string: "")` - How the CLI attempts to invoke a Postgres client.
This value also sets a suitable default for `-exec`, if you did not specify a value.
The default and currently-understood value is `psql`.
You can also specify how the CLI attempts to invoke a Postgres client using the **BOUNDARY_CONNECT_POSTGRES_STYLE** environment variable.

- `-username`  `(string: "")` - The username you want to pass through to the client.
This value may be overridden by credentials sourced from a credential store.
You can also specfiy a username using the **BOUNDARY_CONNECT_USERNAME** environment variable.

@include 'cmd-option-note.mdx'