# Connect from Laravel to Neon

<img src="../img/site-assets/neon.com/_next/static/immutable/media/pattern.1pdcsaq6rik_l.png" alt="">

Pre-built prompt for connecting Laravel to Lakebase Postgres

Laravel is a web application framework with expressive, elegant syntax. Connecting to Neon from Laravel is the same as connecting to a standalone Lakebase Postgres installation from Laravel. Only the connection details differ.

To connect to Neon from Laravel:

::::steps
:::step{title="Create a Neon project"}
If you do not have one already, create a Neon project. Save your connection details including your password. They are required when defining connection settings.

1. Navigate to the [Projects](https://console.neon.tech/app/projects) page in the Neon Console.
2. Click **New Project**.
3. Specify your project settings and click **Create Project**.
:::

:::step{title="Configure the connection"}
Open the `.env` file in your Laravel app, and replace all the database credentials.

```bash
DB_CONNECTION=pgsql
DB_HOST=[neon_hostname]
DB_PORT=5432
DB_DATABASE=[dbname]
DB_USERNAME=[user]
DB_PASSWORD=[password]
```

You can find your database connection details by clicking the **Connect** button in the Console nav. For more information, see [Connect from any application](/guides/postgres-connect-connect-from-any-app).
:::
::::

## Connection issues

With older Postgres clients/drivers, including older PDO\_PGSQL drivers, you may receive the following error when attempting to connect to Neon:

```bash
ERROR: The endpoint ID is not specified. Either upgrade the Postgres client library (libpq) for SNI support or pass the endpoint ID (the first part of the domain name) as a parameter: '&options=endpoint%3D'. See [https://neon.com/sni](/sni) for more information.
```

If you run into this error, please see the following documentation for an explanation of the issue and workarounds: [The endpoint ID is not specified](/guides/postgres-connect-connection-errors#the-endpoint-id-is-not-specified).

- If using a connection string to connect to your database, try [Workaround A. Pass the endpoint ID as an option](/guides/postgres-connect-connection-errors#a-pass-the-endpoint-id-as-an-option). For example:

  ```
  postgresql://[user]:[password]@[neon_hostname]/[dbname]?options=endpoint%3D[endpoint-id]
  ```

  Replace `[endpoint_id]` with your compute's endpoint ID, which you can find in your Neon connection string. It looks similar to this: `ep-cool-darkness-123456`.

- If using database connection parameters, as shown above, try [Workaround D. Specify the endpoint ID in the password field](/guides/postgres-connect-connection-errors#d-specify-the-endpoint-id-in-the-password-field). For example:

  ```
  DB_PASSWORD=endpoint=<endpoint_id>$<password>
  ```

## Schema migration with Laravel

For schema migration with Laravel, see our guide:

- [<img src="../img/site-assets/neon.com/_next/static/immutable/media/pattern.2qd_7vmtgnbf6.png" alt=""> Laravel Migrations Schema migration with Lakebase Postgres and Laravel](/guides/integrations-tooling-guides-laravel-migrations)

## Next steps

- [Add Object Storage](/guides/object-storage-index): S3-compatible file storage that branches with your database
- [Call an LLM with AI Gateway](/guides/ai-gateway-index): Access foundation models from Anthropic, OpenAI, Google, and more with one credential

## Need help?

Join our [Discord Server](https://neon.com/discord) to ask questions or see what others are doing with Neon. For paid plan support options, see [Support](/guides/postgres-introduction-support).

## Related pages

- [Connect a Django application to Neon](./neon-docs-guides-django.md)
- [Connect from Drizzle to Neon](./neon-docs-guides-drizzle.md)
- [Connect from Elixir with Ecto to Neon](./neon-docs-guides-elixir-ecto.md)
- [Connect from Kysely to Neon](./neon-docs-guides-kysely.md)
- [Connect a Ruby on Rails application to Lakebase Postgres](./neon-docs-guides-ruby-on-rails.md)
- [Connect an SQLAlchemy application to Lakebase Postgres](./neon-docs-guides-sqlalchemy.md)
- [Connect a Tortoise ORM application to Neon](./neon-docs-guides-tortoise-orm.md)
- [Connect from Better Drizzle to Neon](./neon-docs-guides-better-drizzle.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
