---
title: "Deploy HTMX+Rust+Axum+Askama+Postgres"
description: "HTMX + Rust + Axum + Askama + PostgreSQL. Full-stack server-rendered app."
category: "Starters"
url: https://railway.com/deploy/htmxrustaxumaskamapostgres
---

# Deploy HTMX+Rust+Axum+Askama+Postgres

HTMX + Rust + Axum + Askama + PostgreSQL. Full-stack server-rendered app.

**[Deploy HTMX+Rust+Axum+Askama+Postgres on Railway](https://railway.com/template/htmxrustaxumaskamapostgres)**

- **Creator:** André Ahlert
- **Category:** Starters

## Template content

### web https://raw.githubusercontent.com/atoolz/railway-htmx-rust-axum-askama-pg/master/assets/icon.svg

- **Source:** https://github.com/atoolz/railway-htmx-rust-axum-askama-pg
- **Health check:** /health

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

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

## Documentation

# Deploy and Host HTMX+Rust+Axum+Askama+Postgres on Railway

**HTMX+Rust+Axum+Askama+Postgres** is a starter for **hypermedia-driven** apps: the server returns HTML fragments and **HTMX** swaps them in the DOM, so you skip a heavy SPA. **Axum** handles HTTP, **Askama** renders **type-checked** templates, **SQLx** speaks to **PostgreSQL**, and **HTMX** plus **Tailwind** load from a CDN—no client framework and no separate frontend build pipeline.

## About Hosting HTMX+Rust+Axum+Askama+Postgres

You deploy a **multi-stage Dockerfile** that runs `cargo build --release` and copies a single binary into a minimal runtime image. The app listens on **`0.0.0.0:$PORT`**, reads **`DATABASE_URL`**, and on startup runs **`CREATE TABLE IF NOT EXISTS`** for the demo todos table (no SQLx offline data). A **`GET /health`** handler returns JSON and checks the database so Railway can gate traffic.

In Railway you add **PostgreSQL**, attach a **web** service from this repo, and set **`DATABASE_URL=${{Postgres.DATABASE_URL}}`** (use the exact name of your Postgres service). Builds run on every push when GitHub is connected; the private network keeps app-to-DB traffic off the public internet.

## Common Use Cases

- **Internal tools and CRUD dashboards** where you want dynamic UI without React, Vue, or a dedicated SPA repo.
- **Learning HTMX** with a production-shaped Rust stack: routes, forms, partials, and a real Postgres backend.
- **Fast prototypes** that still compile to a small static binary and deploy cleanly on a PaaS.

## Dependencies for HTMX+Rust+Axum+Askama+Postgres Hosting

- A **PostgreSQL** instance (Railway Postgres plugin or any URL compatible with SQLx + `DATABASE_URL`).
- A **web** service using this repo’s **Dockerfile** and a valid **`DATABASE_URL`** at runtime.

### Deployment Dependencies

- [HTMX documentation](https://htmx.org/docs/)
- [Axum](https://docs.rs/axum/latest/axum/)
- [Askama](https://djc.github.io/askama/)
- [SQLx](https://github.com/launchbadge/sqlx)
- [Railway documentation](https://docs.railway.com/)

### Implementation Details

- **`DATABASE_URL`**: on the web service, reference the DB plugin, e.g. `DATABASE_URL="${{Postgres.DATABASE_URL}}"`.
- **Templates**: Askama compiles `templates/*.html` at **build** time; changing markup requires a **rebuild**.
- **Repo hygiene**: keep **`target/`** out of deploy uploads (e.g. `.gitignore`) so Git/CLI deploys stay small.

## Why Deploy HTMX+Rust+Axum+Askama+Postgres 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 HTMX+Rust+Axum+Askama+Postgres 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

- [open-excalidraw](https://railway.com/deploy/open-excalidraw) — Self-hostable collaborative drawing built on Excalidraw
- [caring-vibrancy](https://railway.com/deploy/caring-vibrancy) — Deploy and Host caring-vibrancy with Railway
- [Appsmith](https://railway.com/deploy/appsmith-1) — Low-code platform for internal tools, dashboards, and admin panels.

Open this page in a browser: https://railway.com/deploy/htmxrustaxumaskamapostgres
