Deploy PG postgis & pg_vector
PostgreSQL with pgvector and PostGIS for AI embeddings and geospatial data
Postgres
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
- pgvector: https://github.com/pgvector/pgvector
- PostGIS: https://postgis.net
- PostgreSQL docs: https://www.postgresql.org/docs/
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 proxyPGHOST,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
Postgres
Rooler-ai/postgres-ha