# Source: https://neon.com/llms/connect-connect-from-any-app.txt

# Connect from any application

> The document outlines the steps for connecting to a Neon database from various applications, detailing configuration requirements and connection string formats specific to Neon's platform.

## Source

- [Connect from any application HTML](https://neon.com/docs/connect/connect-from-any-app): The original HTML version of this documentation

What you will learn:
- Where to find database connections details
- Where to find example connection snippets
- Protocols supported by Neon

Related topics:
- [Choosing a driver and connection type](https://neon.com/docs/connect/choose-connection)
- [Neon Local Connect](https://neon.com/docs/local/neon-local-connect)
- [Connect to Neon securely](https://neon.com/docs/connect/connect-securely)
- [Connection pooling](https://neon.com/docs/connect/connection-pooling)
- [Connect with psql](https://neon.com/docs/connect/query-with-psql-editor)

You can connect to your Neon database from any application. The standard method is to copy your [connection string](https://neon.com/docs/connect/connect-from-any-app#get-a-connection-string-from-the-neon-console) from the Neon console and use it in your app or client. For local development, you can also use the [Neon Local Connect extension](https://neon.com/docs/connect/connect-from-any-app#connect-with-the-neon-local-connect-extension), which lets you connect using a simple localhost connection string.

## Get a connection string from the Neon console

When connecting to Neon from an application or client, you connect to a database in your Neon project. In Neon, a database belongs to a branch, which may be the default branch of your project (`production`) or a child branch.

You can find the connection details for your database by clicking the **Connect** button on your **Project Dashboard**. This opens the **Connect to your database** modal. Select a branch, a compute, a database, and a role. A connection string is constructed for you.



Neon supports both pooled and direct connections to your database. Neon's connection pooler supports a higher number of concurrent connections, so we provide pooled connection details in the **Connect to your database** modal by default, which adds a `-pooler` option to your connection string. If needed, you can get direct database connection details from the modal disabling the **Connection pooling** toggle. For more information about pooled connections, see [Connection pooling](https://neon.com/docs/connect/connection-pooling#connection-pooling).

A Neon connection string includes the role, password, hostname, and database name.

```text
postgresql://alex:AbC123dEf@ep-cool-darkness-a1b2c3d4-pooler.us-east-2.aws.neon.tech/dbname?sslmode=require&channel_binding=require
             ^    ^         ^                         ^                              ^
       role -|    |         |- hostname               |- pooler option               |- database
                  |
                  |- password
```

   **Note**: The hostname includes the ID of the compute, which has an `ep-` prefix: `ep-cool-darkness-123456`. For more information about Neon connection strings, see [connection string](https://neon.com/docs/reference/glossary#connection-string).

You can use the details from the **Connect to your database** modal to configure your database connection. For example, you might place the connection details in an `.env` file, assign the connection string to a variable, or pass the connection string on the command-line.

**.env file**

```text
PGHOST=ep-cool-darkness-a1b2c3d4-pooler.us-east-2.aws.neon.tech
PGDATABASE=dbname
PGUSER=alex
PGPASSWORD=AbC123dEf
PGPORT=5432
```

**Variable**

```text
DATABASE_URL="postgresql://alex:AbC123dEf@ep-cool-darkness-a1b2c3d4-pooler.us-east-2.aws.neon.tech/dbname?sslmode=require&channel_binding=require"
```

**Command-line**

```bash
psql postgresql://alex:AbC123dEf@ep-cool-darkness-a1b2c3d4-pooler.us-east-2.aws.neon.tech/dbname?sslmode=require&channel_binding=require
```

   **Note**: Neon requires that all connections use SSL/TLS encryption, but you can increase the level of protection by configuring the `sslmode` option. For more information, see [Connect to Neon securely](https://neon.com/docs/connect/connect-securely).

## Connect with the Neon Local Connect extension

For local development, you can use the [Neon Local Connect extension](https://neon.com/docs/local/neon-local-connect) to connect to any Neon branch using a simple localhost connection string. Available for VS Code, Cursor, Windsurf, and other VS Code-compatible editors, this extension lets you:

- Connect to any branch using `postgres://neon:npg@localhost:5432/<database_name>`
- Switch branches without updating your connection string
- Create and manage ephemeral branches directly from your editor
- Access the Neon SQL Editor and Table View with one click

Your app connects to `localhost:5432` while Neon Local routes traffic to your actual Neon branch in the cloud. This eliminates the need to manage different connection strings for different branches during development.

## Where can I find my password?

It's included in your Neon connection string. Click the **Connection** button on your **Project Dashboard** to open the **Connect to your database** modal.

### Save your connection details to 1Password

If have a [1Password](https://1password.com/) browser extension, you can save your database connection details to 1Password directly from the Neon Console. In your **Project Dashboard**, click **Connect**, then click **Save in 1Password**.



## What port does Neon use?

Neon uses the default Postgres port, `5432`.

## Connection examples

The **Connect to your database** modal provides connection examples for different frameworks and languages, constructed for the branch, database, and role that you select.



See our [frameworks](https://neon.com/docs/get-started/frameworks) and [languages](https://neon.com/docs/get-started/languages) guides for more connection examples.

## Network protocol support

Neon projects provisioned on AWS support both [IPv4](https://en.wikipedia.org/wiki/Internet_Protocol_version_4) and [IPv6](https://en.wikipedia.org/wiki/IPv6) addresses. Neon projects provisioned on Azure support IPv4.

Additionally, Neon provides a low-latency serverless driver that supports connections over WebSockets and HTTP. Great for serverless or edge environments where connections over TCP may not be not supported. For further information, refer to our [Neon serverless driver](https://neon.com/docs/serverless/serverless-driver) documentation.

## Connection notes

- Some older Postgres client libraries and drivers, including older `psql` executables, are built without [Server Name Indication (SNI)](https://neon.com/docs/reference/glossary#sni) support, which means that a connection workaround may be required. For more information, see [Connection errors: The endpoint ID is not specified](https://neon.com/docs/connect/connection-errors#the-endpoint-id-is-not-specified).
- Some Java-based tools that use the pgJDBC driver for connecting to Postgres, such as DBeaver, DataGrip, and CLion, do not support including a role name and password in a database connection string or URL field. When you find that a connection string is not accepted, try entering the database name, role, and password values in the appropriate fields in the tool's connection UI when configuring a connection to Neon. For examples, see [Connect a GUI or IDE](https://neon.com/docs/connect/connect-postgres-gui#connect-to-the-database).
- When connecting from BI tools like Metabase, Tableau, or Power BI, we recommend using a **read replica** instead of your main database compute. BI tools often run long or resource-intensive queries, which can impact performance on your primary branch. Read replicas can scale independently and handle these workloads without affecting your main production traffic. To learn more, see [Neon read replicas](https://neon.com/docs/introduction/read-replicas).