Deploy PG postgis & pg_vector

PostgreSQL with pgvector and PostGIS for AI embeddings and geospatial data

Deploy PG postgis & pg_vector

Just deployed

/var/lib/postgresql/data

Deploy and Host Postgres with pgvector + PostGIS on Railway

A production-ready PostgreSQL database with two of the most popular extensions preinstalled: pgvector for storing and searching vector embeddings, and PostGIS for geospatial data and queries. Ideal for AI apps that also need location awareness, such as semantic search over places, RAG with geo filters, or recommendation engines.

About Hosting Postgres with pgvector + PostGIS

This template runs a single PostgreSQL service on a persistent Railway volume, so your data survives redeploys and restarts. Credentials are generated automatically and exposed as service variables, so you can reference them from any other service in your project. Both extensions ship in the image; you only need to enable them once per database.

Common Use Cases

  • Retrieval-augmented generation (RAG) and semantic search with vector embeddings
  • Location-based search, mapping, routing and geofencing
  • Hybrid queries, e.g. "find similar listings within 5 km"
  • Recommendation systems combining similarity and proximity

Dependencies for Postgres with pgvector + PostGIS Hosting

  • A Railway volume (attached automatically) for persistent storage

Deployment Dependencies

Getting Started

After deploy, connect with the DATABASE_URL variable and enable the extensions:

CREATE EXTENSION IF NOT EXISTS vector;
CREATE EXTENSION IF NOT EXISTS postgis;

Example table using both:

CREATE TABLE places (
  id BIGSERIAL PRIMARY KEY,
  name TEXT,
  embedding VECTOR(1536),
  location GEOGRAPHY(POINT, 4326)
);

CREATE INDEX ON places USING hnsw (embedding vector_cosine_ops);
CREATE INDEX ON places USING gist (location);

Connecting From Other Services

Reference these variables from your app service:

  • ${{Postgres.DATABASE_URL}} – private network connection (recommended)
  • ${{Postgres.DATABASE_PUBLIC_URL}} – public connection via TCP proxy
  • PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE

Why Deploy Postgres with pgvector + PostGIS 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 Postgres with pgvector + PostGIS 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.


Template Content

More templates in this category

View Template
RustFS | (Just Updated) S3 Object Store, Public URL and Keys Set
S3-compatible object store, keys and public URL preset, volume kept

SuperSlowSloth
0
View Template
TimescaleDB
A PostgreSQL-based time-series database for analytics on Railway.

Rakit
1
View Template
Garage S3 Storage
Ultra-light S3 server: fast, open-source, plug-and-play.

PROJETOS
8