> For the complete documentation index, see [llms.txt](https://docs.flowiseai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flowiseai.com/integrations/langchain/vector-stores/postgres.md).

# Postgres

Upsert embedded data and perform similarity search upon query using pgvector on Postgres.

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fgit-blob-e2676a66e844944731feb69b9dba62d9d62fc62c%2Fimage%20(163).png?alt=media" alt="" width="292"><figcaption><p>Postgres Node</p></figcaption></figure>

There are multiple methods to connect to Postgres based on how your instance is set up. Below is an example of a local configuration using a prebuilt Docker image provided by the pgvector team.

Create a file named `docker-compose.yml` with the content below:

```yaml
# Run this command to start the database:
# docker-compose up --build
version: "3"
services:
  db:
    hostname: 127.0.0.1
    image: pgvector/pgvector:pg16
    ports:
      - 5432:5432
    restart: always
    environment:
      - POSTGRES_DB=api
      - POSTGRES_USER=myuser
      - POSTGRES_PASSWORD=ChangeMe
    volumes:
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql
```

`docker compose up` to start the Postgres container.

Create new credential with the configured user and password:

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fgit-blob-ee42d0032ac01a4c5f3d8190218fd971b575bcab%2Fimage%20(50).png?alt=media" alt="" width="526"><figcaption></figcaption></figure>

Fill in the node's field with values configured in `docker-compose.yml`. For example:

* Host: **localhost**
* Database: **api**
* Port: **5432**

Voila! You have now successfully setup Postgres Vector ready to be used.

### Troubleshooting

If both Flowise and Postgres are running on Docker, you might see the error: <mark style="color:red;">**AggregateError**</mark>.

Try to change the Host value from `localhost` to `host.docker.internal`

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2FuOSL9UlhNtFNRI5PMUkk%2Fimage.png?alt=media&amp;token=a7224858-e2f2-4703-862d-31cfe7d182a2" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flowiseai.com/integrations/langchain/vector-stores/postgres.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
