---
title: "Deploy Microsoft SQL Server"
description: "SQL Server 2025 Express (MSSQL) on a volume, fixed to run on Railway disks"
category: "Storage"
url: https://railway.com/deploy/mssql
---

# Deploy Microsoft SQL Server

SQL Server 2025 Express (MSSQL) on a volume, fixed to run on Railway disks

**[Deploy Microsoft SQL Server on Railway](https://railway.com/template/mssql)**

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

- **Creator:** Two Workspaces
- **Category:** Storage

## Template content

### MSSQL https://raw.githubusercontent.com/two-workspaces/mssql/main/icon.svg

- **Image:** ghcr.io/two-workspaces/mssql:d41d9d6

## Documentation

# Deploy and Host Microsoft SQL Server on Railway

[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/new/template/mssql?referralCode=sLjDXb&utm_medium=integration&utm_source=button&utm_campaign=mssql)

Microsoft SQL Server (MSSQL) is Microsoft's relational database, the usual backend for .NET, Entity Framework and many business apps. This template runs SQL Server 2025 on Railway with a persistent volume, a first database, and a TCP proxy for SSMS, Azure Data Studio and sqlcmd.

This is a community template, not made or supported by Microsoft.

## About Hosting Microsoft SQL Server

SQL Server's official image does not start cleanly on a Railway volume. Railway mounts the volume owned by root while SQL Server runs as its own user, and the volume's disk reports 16 KB sectors, which SQL Server doesn't support: it logs "misaligned log IOs" while opening `master` and then crashes. Each crash also writes a full memory dump of about 1 GB to the volume, so a few restarts fill it.

This template fixes all of that. A small entrypoint gives the volume to the SQL Server user, turns on trace flag 1800 (Microsoft's fix for disks with large sectors, which aligns log writes to 4 KB), and keeps crash dumps small. On a plan with too little memory it does not crash-loop: it logs a message saying what to change and waits.

**Connect from another service:** reference `${{MSSQL.MSSQL_URL}}` or, for .NET, `${{MSSQL.MSSQL_CONNECTION_STRING}}`. Both use Railway's private network.

**Connect from your computer:** use `MSSQL_PUBLIC_CONNECTION_STRING`, or in SSMS enter the server as `host,port` from the TCP proxy (for example `tramway.proxy.rlwy.net,12345`), SQL Server Authentication, login `sa`, the password from `MSSQL_SA_PASSWORD`, and tick **Trust server certificate**.

## Common Use Cases

- A database for an ASP.NET Core or Entity Framework app hosted on Railway
- Running an app that only supports SQL Server
- A development or staging copy of a production SQL Server database

## Dependencies for Microsoft SQL Server Hosting

- A Railway plan with 2 GB of memory or more for the service (Hobby or above)

### Deployment Dependencies

- [SQL Server on Linux documentation](https://learn.microsoft.com/sql/linux/sql-server-linux-overview)
- [SQL Server container image](https://mcr.microsoft.com/product/mssql/server/about)
- [Template source](https://github.com/two-workspaces/mssql)

### Implementation Details

- **Tested on Railway:** first boot creates the `railway` database; connections work over the private network and through the TCP proxy; data survives redeploys; a redeploy shuts SQL Server down cleanly; 200,000 rows (about 200 MB) insert in under 7 seconds at a 2 GB limit.
- **Memory:** SQL Server needs 2 GB. At 1 GB it can't start, and at 1.5 GB it starts but runs out of memory under load and takes the database offline. Free (0.5 GB) and Trial (1 GB) plans can't run it: the service then stays up and logs what to change instead of failing. On Hobby, if you set a memory limit on the service, make it 2 GB or more.
- **Edition:** `MSSQL_PID` is `Express` by default: free for production, with a 10 GB limit per database and about 1.4 GB of buffer pool. Set it to `Developer` for every feature (not licensed for production), or to a product key for Standard or Enterprise.
- **First database and password:** `MSSQL_DB` is created, and `MSSQL_SA_PASSWORD` set, only on first boot, when the volume is empty. To change the password later, run `ALTER LOGIN sa WITH PASSWORD = '...'`, then update the variable. The generated password is letters and digits only, so it is safe in URLs; if you use symbols, URL-encode them in `MSSQL_URL`.
- **Connection formats:** `MSSQL_URL` is `sqlserver://sa:PASSWORD@HOST:1433?database=railway`, the form Go's go-mssqldb and many ORMs read. `MSSQL_CONNECTION_STRING` is the ADO.NET form. Prisma and JDBC use their own formats, built from the same host, port, database and password.
- **Encryption:** SQL Server uses a self-signed certificate, so clients need `TrustServerCertificate=True` (or `-C` in sqlcmd).
- **Image:** `ghcr.io/two-workspaces/mssql`, built from this repository's Dockerfile on `mcr.microsoft.com/mssql/server:2025-CU11-ubuntu-24.04`. The license terms are Microsoft's; `ACCEPT_EULA=Y` accepts them.

## Why Deploy Microsoft SQL Server 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 Microsoft SQL Server 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

- [RustFS | (Just Updated) S3 Object Store, Public URL and Keys Set](https://railway.com/deploy/rustfs-or-just-updated-s3-object-store-p) — S3-compatible object store, keys and public URL preset, volume kept
- [TimescaleDB](https://railway.com/deploy/timescaledb-railway-template) — A PostgreSQL-based time-series database for analytics on Railway.
- [Neo4j 2026.10 Community](https://railway.com/deploy/neo4j-202610-community) — Neo4j graph database with APOC, Browser, Bolt TCP proxy and a volume

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