---
title: "Deploy Mathesar"
description: "Spreadsheet-style UI for Postgres, with the admin created at deploy"
category: "Other"
url: https://railway.com/deploy/mathesar-1
---

# Deploy Mathesar

Spreadsheet-style UI for Postgres, with the admin created at deploy

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

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

- **Creator:** Agaz Self-Host
- **Category:** Other

## Template content

### Mathesar https://cdn.jsdelivr.net/gh/selfhst/icons/svg/mathesar.svg

- **Image:** mathesar/mathesar:0.12.0@sha256:091757cb01fec9718d627aa672fdd565d76a2da6b53cdab6264e9fbc031472a4
- **Start command:** `bash -c 'set -e; cd /code; export DJANGO_SETTINGS_MODULE=config.settings.production WEB_CONCURRENCY="${WEB_CONCURRENCY:-3}" MATHESAR_ADMIN_USERNAME="${MATHESAR_ADMIN_USERNAME:-admin}"; python -m mathesar.install; python manage.py shell -c "import os; from django.contrib.auth import get_user_model as g; U=g(); p=os.environ.get(\"MATHESAR_ADMIN_PASSWORD\"); n=os.environ[\"MATHESAR_ADMIN_USERNAME\"]; e=os.environ.get(\"MATHESAR_ADMIN_EMAIL\", \"\"); print(\"Admin already exists, not changing it\") if U.objects.filter(is_superuser=True).exists() else (U.objects.create_superuser(n, e, p), print(\"Created admin user \" + n)) if p else print(\"MATHESAR_ADMIN_PASSWORD is empty: open the site now and create the admin\")"; exec ./bin/mathesar run -n -e -p "${PORT:-8000}"'`
- **Health check:** /healthz/ready/
- **Public domain:** Yes

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18.6@sha256:4fc833b43d2aaf6ecc9b18615f5533602b723a32d0e2efe2dae8ca0f7217c863

## Documentation

# Deploy and Host Mathesar on Railway

Mathesar is an open-source web app that gives you a spreadsheet-like interface to PostgreSQL. You can browse, edit, filter and relate data, build forms and explorations, and manage tables and columns without writing SQL. It works directly on your Postgres tables and uses Postgres roles and permissions for access control.

## About Hosting Mathesar

Mathesar needs a web service and a PostgreSQL server. This template runs the official `mathesar/mathesar` 0.12.0 image, pinned by digest, next to Railway's Postgres 18. On every start the web service applies database migrations and then serves the app on Railway's port. Mathesar keeps its own settings in the Postgres database, and you can create new databases on the same server or connect other Postgres servers from the UI. The first admin account is created from deploy variables with a generated password, so nobody else can claim a fresh instance. Imported files live on a volume, and a readiness endpoint drives Railway's health check.

## Common Use Cases

* Give non-technical teammates a safe spreadsheet-style editor for an existing Postgres database
* Build a lightweight internal tool or data-entry app with forms, without writing frontend code
* Explore, clean up and relate imported CSV data stored in Postgres

## Dependencies for Mathesar Hosting

* PostgreSQL (included: Railway's Postgres 18.6)
* A volume for uploaded and imported files (included)

### Deployment Dependencies

* Mathesar on GitHub: https://github.com/mathesar-foundation/mathesar
* Mathesar 0.12.0 release notes: https://github.com/mathesar-foundation/mathesar/releases/tag/0.12.0
* Mathesar Docker image: https://hub.docker.com/r/mathesar/mathesar
* Mathesar documentation: https://docs.mathesar.org

### Implementation Details

**Signing in:** open the Railway domain and sign in as `admin` with the password in the Mathesar service's `MATHESAR_ADMIN_PASSWORD` variable. The admin is only created when no admin exists yet, so changing that variable later doesn't change the password. Change it in Mathesar's own settings instead. To use a different username, set `MATHESAR_ADMIN_USERNAME` before the first deploy.

**Adding data:** choose "Connect Database", then either create a new database on the included Postgres server (optionally with sample data) or connect any other Postgres server you can reach.

**Custom domain:** add it to `ALLOWED_HOSTS` (comma-separated), for example `${{RAILWAY_PUBLIC_DOMAIN}},data.example.com`.

**Keep `SECRET_KEY` unchanged:** Mathesar uses it to encrypt the passwords of the databases you connect.

## Why Deploy Mathesar 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 Mathesar 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

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

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