> ## Documentation Index
> Fetch the complete documentation index at: https://docs.porter.run/llms.txt
> Use this file to discover all available pages before exploring further.

# porter datastore connect

> Create a secure local tunnel to connect to Porter-provisioned Postgres and Redis datastores for local debugging and database administration

`porter datastore connect` creates a secure tunnel to connect to Porter-provisioned datastores from your local machine.

## Prerequisites

* You've logged in to the Porter CLI after running [porter auth login](/standard/cli/command-reference/porter-auth)
* You're connected to the correct project by running [porter config set-project](/standard/cli/command-reference/porter-config)
* You have a Porter-provisioned datastore (PostgreSQL, Redis, etc.)

***

## Usage

```bash theme={null}
porter datastore connect [DATASTORE_NAME] [flags]
```

**Options:**

| Flag     | Description                               |
| -------- | ----------------------------------------- |
| `--port` | Local port for the tunnel (default: 8122) |

***

## Examples

<CodeGroup>
  ```bash Connect to Datastore theme={null}
  porter datastore connect my-postgres
  ```

  ```bash Custom Port theme={null}
  porter datastore connect my-postgres --port 5433
  ```
</CodeGroup>

***

## Connecting to Your Datastore

While the tunnel is running, connect using your preferred client in a separate terminal:

<CodeGroup>
  ```bash PostgreSQL theme={null}
  psql -h 127.0.0.1 -p 8122 -U postgres -d postgres
  ```

  ```bash Redis theme={null}
  redis-cli -p 8122 -a [YOUR_DATASTORE_PASSWORD] --tls
  ```
</CodeGroup>

<Info>
  The tunnel stays open until you press `CTRL-C`. Keep the terminal open while you need access to the datastore.
</Info>

<Warning>
  The connection credentials are displayed when the tunnel starts. Make sure to note the password if you need it for your client.
</Warning>
