---
title: "Deploy Terraria server"
description: "Self-host a persistent terraria TShock server using Docker Image"
category: "Other"
url: https://railway.com/deploy/terraria-dedicated-server
---

# Deploy Terraria server

Self-host a persistent terraria TShock server using Docker Image

**[Deploy Terraria server on Railway](https://railway.com/template/terraria-dedicated-server)**

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

- **Creator:** Xav's Projects
- **Category:** Other
- **Total deploys:** 46

## Template content

### Terraria-Selfhost https://terraria.wiki.gg/images/App_icon_1.3_Update.png

- **Source:** https://github.com/XavTo/Terraria-Selfhost
- **Health check:** /health

## Documentation

# Deploy and Host Terraria Dedicated Server on Railway

For a persistent Terraria PC multiplayer server on Railway, use [this TShock template](https://railway.com/deploy/terraria-dedicated-server). It pins TShock 6.2.1 for Terraria PC 1.4.5.8, starts without interactive setup and stores the world on a volume. Players connect using Railway's public TCP proxy hostname and external port, not the internal port 7777. Match the client version to the server; this is a game server, not a browser-playable Terraria client.

## About Hosting Terraria Dedicated Server

This server pins TShock 6.2.1 for **Terraria PC 1.4.5.8**. Clients must use the
matching game version. The container runs without interactive setup or a TTY.

## Connect

Use the **TCP proxy hostname and external port** shown in Railway's service
Networking settings. Port 7777 is the internal game port, not the external port.

## Variables

| Variable | Default | Purpose |
| --- | --- | --- |
| WORLD_FILENAME | world.wld | World filename inside the persistent volume; spaces are supported. |
| WORLD_SIZE | 2 | New worlds only: 1 small, 2 medium, 3 large. Existing worlds are retained. |
| MAXPLAYERS | 8 | Maximum player count. |
| PASSWORD | empty | TShock server password required for new players. |
| MOTD | empty | Optional text shown to joining players. |
| SERVER_PORT | 7777 | Internal game port; keep the Railway TCP proxy target in sync. |
| PORT | 8080 | Internal HTTP readiness port, separate from the game port. |

## Storage and shutdown

Mount one Railway volume at `/data`. Existing layout is preserved:

- `/data/world`: world files, TShock configuration, account database and MOTD.
- `/data/logs`: TShock logs.
- `/data/plugins`: plugins loaded through `/tshock/ServerPlugins`.

Bundled TShock assemblies are synchronized with the pinned server; additional
plugins in the volume are retained. A replacement container loads the same world.
On SIGTERM the supervisor sends the console `exit` command, allowing TShock to
save the world before the process exits. Set Railway's deployment draining period
to 60 seconds for this saving shutdown.

`GET /health` returns 503 while the world is being generated and 200 only when
the game process is running and its TCP listener is available. Configure this
path as Railway's healthcheck, with a 300-second startup timeout. No public HTTP
domain is required.

World generation needs extra memory. A medium world used about 0.46 GB in the
initial Railway validation; this is an observation, not a memory limit or a
guarantee for larger worlds, plugins or more players. Prefer a small world on
constrained instances. Back up the volume before changing TShock versions.


## Common Use Cases

- Persistent multiplayer worlds for friends and small communities.
- Password-protected games with TShock permissions and custom plugins.

## Dependencies for Terraria Dedicated Server Hosting

One service, a persistent Railway volume at `/data`, and a TCP proxy targeting port 7777. No external database is needed.

### Deployment Dependencies

- [TShock](https://github.com/Pryaxis/TShock/releases/tag/v6.2.1)
- [Terraria container image](https://github.com/ryansheehan/terraria)
- [Railway healthchecks](https://docs.railway.com/deployments/healthchecks)

## Why Deploy Terraria Dedicated Server on Railway?

Deploy the game server with persistent storage and TCP networking in one project. Railway waits for the game listener before completing the deployment.

## Other deployment choices from this publisher

- [For a general browser-accessible Linux desktop instead: Ubuntu](https://railway.com/deploy/ubuntu-2)


## 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/terraria-dedicated-server
