Deploy pREST

Instant REST and MCP API for Postgres, with JWT auth enforced

Deploy pREST

Just deployed

/var/lib/postgresql/data

Deploy and Host pREST on Railway

pREST (prestd) serves an instant REST API and an MCP endpoint on top of PostgreSQL: CRUD on every table, filtering, joins, custom SQL routes and a built-in Studio UI, without writing a backend.

About Hosting pREST

This template runs pREST against a private Railway Postgres database with authentication forced on.

  • pREST service (prest/prest:v2) on port 3000 with a public domain
  • Postgres service with a persistent volume, reachable only over the private network by pREST
  • Generated secrets: PREST_JWT_KEY (token signing key) and PREST_ADMIN_PASSWORD (admin login)
  • JWT auth enforced: every table, catalog, query and /_mcp request without a valid token gets 401; only /auth, /_health, /_ready and the static Studio assets are open
  • A readable pre-deploy step creates the auth table and seeds the admin user (bcrypt hash) on first deploy

After deploy:

  1. Open the pREST service Variables tab and copy PREST_ADMIN_PASSWORD (username: PREST_ADMIN_USER, default admin).
  2. Get a token: POST https://YOUR-RAILWAY-DOMAIN/auth with JSON body {"username":"admin","password":"..."}. Tokens are valid for 6 hours.
  3. Call the API with the header Authorization: Bearer TOKEN, for example GET https://YOUR-RAILWAY-DOMAIN/railway/public/your_table (database is railway, schema public).
  4. Create your tables with the Postgres service Data tab or any SQL client; pREST picks them up immediately.
  5. Point MCP clients at https://YOUR-RAILWAY-DOMAIN/_mcp with the same bearer token. Studio is at https://YOUR-RAILWAY-DOMAIN/_studio.
  6. Changing PREST_ADMIN_PASSWORD later does not rotate the existing user; the seed runs only once. Update the password column of public.prest_users with a bcrypt hash instead.

Common Use Cases

  • Expose an existing Postgres schema as a REST API for frontends, scripts and no-code tools
  • Give AI agents read access to your data through the authenticated MCP endpoint
  • Prototype a backend quickly with CRUD, filters and custom SQL routes
  • Run an internal data API without writing or maintaining API code

Dependencies for pREST Hosting

Deployment Dependencies

Implementation Details

  • pREST reads DATABASE_URL from the Railway Postgres service over the private network.
  • pREST silently turns auth off when the JWT key is missing or shorter than 32 characters, so the template always generates a 64-character key.
  • The admin user is seeded with prestd migrate up from the PREST_SEED_SQL variable, using pgcrypto bcrypt; the migration is recorded in public.schema_migrations, so redeploys do not overwrite it.
  • Authenticated users can read and write all tables (pREST public mode). Enable pREST ACLs (PREST_ACCESS_RESTRICT plus table rules in a config file) if you need per-table permissions.

Why Deploy pREST 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 pREST 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
Rocky Linux
Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
51
View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

Lucas
71
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta
52