---
title: "Deploy pgvector"
description: "pgvector 0.8.7 on PostgreSQL 18: vector search with TLS and a volume"
category: "Storage"
url: https://railway.com/deploy/pgvector-1
---

# Deploy pgvector

pgvector 0.8.7 on PostgreSQL 18: vector search with TLS and a volume

**[Deploy pgvector on Railway](https://railway.com/template/pgvector-1)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/pgvector-1/manifest.json

- **Creator:** Agaz Self-Host
- **Category:** Storage
- **Total deploys:** 1

## Template content

### pgvector https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/postgres.png

- **Source:** https://github.com/aalfath/pgvector-railway-template

## Documentation

# Deploy and Host pgvector on Railway

pgvector is an open-source PostgreSQL extension for vector similarity search. It stores embeddings next to your relational data and finds nearest neighbours by L2, inner product, cosine, L1, Hamming or Jaccard distance, with exact search or approximate HNSW and IVFFlat indexes, while you keep full SQL, joins, transactions and every Postgres client library.

## About Hosting pgvector

Hosting pgvector means running PostgreSQL with the extension installed, a persistent disk for the data directory, a strong superuser password and network access for your applications. This template builds the official `pgvector/pgvector` image (pgvector 0.8.7 on PostgreSQL 18.7), pinned by digest, from a public GitHub repo. Data lives on a Railway volume, the password is generated at deploy time, and TLS is on with a self-signed certificate. The `vector` extension is already created, and memory settings are tuned for index builds, including parallel HNSW builds that fail on stock containers with a small `/dev/shm`. Services in the same project connect over the private network; a TCP proxy gives a public URL.

## Common Use Cases

* Retrieval-augmented generation (RAG): store document chunks and their embeddings, then fetch the closest ones for an LLM prompt
* Semantic search and recommendations over products, articles, images or support tickets
* A vector store for AI frameworks and apps such as LangChain, LlamaIndex, n8n, Flowise or Dify, next to your normal tables

## Dependencies for pgvector Hosting

* A Railway volume for the PostgreSQL data directory (included in the template)
* A PostgreSQL client or driver in your application, plus an embedding model of your choice (OpenAI, Cohere, Ollama and others)

### Deployment Dependencies

* pgvector on GitHub: https://github.com/pgvector/pgvector
* pgvector changelog: https://github.com/pgvector/pgvector/blob/master/CHANGELOG.md
* Official Docker image: https://hub.docker.com/r/pgvector/pgvector
* Template source and changelog: https://github.com/aalfath/pgvector-railway-template

### Implementation Details

Connect another service in the same project by setting its variable to the private URL:

```
DATABASE_URL=${{pgvector.DATABASE_URL}}
```

The `vector` extension is already created in the default `railway` database and in `template1`, so new databases get it too. Create a table and an HNSW index, then query it with pgvector's distance operators (see Querying in the pgvector README):

```sql
CREATE TABLE items (id bigserial PRIMARY KEY, content text, embedding vector(1536));
CREATE INDEX ON items USING hnsw (embedding vector_cosine_ops);
```

On first start the template sets `shared_buffers` and `maintenance_work_mem` to 512MB with `ALTER SYSTEM`; change them later with `ALTER SYSTEM SET maintenance_work_mem = '2GB';` and a redeploy. Updates to the template repo reach you as Railway's "update available" notice; after a pgvector update, run `ALTER EXTENSION vector UPDATE;` in each database. PostgreSQL major upgrades are never applied automatically.

## Why Deploy pgvector on Railway?


Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying pgvector on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.



## Similar templates

- [RustFS | (Just Updated) S3 Object Store, Public URL and Keys Set](https://railway.com/deploy/rustfs-or-just-updated-s3-object-store-p) — S3-compatible object store, keys and public URL preset, volume kept
- [TimescaleDB](https://railway.com/deploy/timescaledb-railway-template) — A PostgreSQL-based time-series database for analytics on Railway.
- [Neo4j 2026.10 Community](https://railway.com/deploy/neo4j-202610-community) — Neo4j graph database with APOC, Browser, Bolt TCP proxy and a volume

Open this page in a browser: https://railway.com/deploy/pgvector-1
