Deploy Terraria server
Self-host a persistent terraria TShock server using Docker Image
Terraria-Selfhost
Just deployed
/data
Deploy and Host Terraria Dedicated Server on Railway
Persistent TShock multiplayer server for Terraria PC 1.4.5.8, with a public TCP proxy.
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
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.
Template Content
Terraria-Selfhost
XavTo/Terraria-Selfhost