Dedicated Terraria server for 2D sandbox adventure with friends — host a persistent world with optional TShock modded server management.
Grab the automated bash script from GitHub to follow along with the video.
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/gaming/terraria/terraria-ubuntu.sh
chmod +x terraria-ubuntu.sh
sudo bash terraria-ubuntu.sh
The script installs Docker if needed, then pulls the Terraria dedicated server image and starts the container. The server uses the official Terraria dedicated server binary running inside a Docker container for easy management and updates.
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/gaming/terraria/terraria-ubuntu.sh
chmod +x terraria-ubuntu.sh
sudo bash terraria-ubuntu.sh
Edit the serverconfig.txt file in the server data volume to configure your server. Key settings include worldname (world file to load or create), password (join password), maxplayers (maximum simultaneous players), and difficulty (0=normal, 1=expert, 2=master, 3=journey). Set autocreate to 1/2/3 for small/medium/large world auto-generation on first start.
# Edit server config
nano /path/to/terraria/serverconfig.txt
# Key settings:
# worldname=MyWorld
# password=yourpassword
# maxplayers=16
# difficulty=0
# autocreate=2
Launch Terraria, go to Multiplayer, and select "Join via IP". Enter your server's IP address and port 7777. Select your character and enter the server password if one is set. You will be placed in the world and can start playing immediately with other connected players.
# Connect address:
<your-server-ip>:7777
World files (.wld) are stored in the worlds/ directory inside the data volume. Copy them to your backup location regularly. For advanced server management, consider switching to TShock — it adds user accounts, permissions, anti-cheat, plugins, and a REST API for remote management. Monitor the server console with 'docker attach terraria-server' to send commands in real time.
# Attach to server console
docker attach terraria-server
# Backup world file
cp /path/to/terraria/worlds/MyWorld.wld \
/backups/MyWorld_$(date +%F).wld
# Detach without stopping: Ctrl+P then Ctrl+Q
| Port | Purpose |
|---|---|
| 7777 (TCP) | Game traffic |
Terraria is a 2D action-adventure sandbox game combining exploration, building, and combat across a procedurally generated world. A dedicated server allows a persistent world where friends can join anytime without the host needing to be online.
A self-hosted Terraria server keeps the world alive 24/7, supports multiple simultaneous players, and gives you control over world settings, player slots, and server password. TShock (a popular server fork) adds admin commands, plugins, and anti-grief tools.
Terraria uses TCP port 7777 for player connections. Open port 7777 TCP in your firewall. If using TShock's REST API, port 7878 is also used. Keep the REST API port firewalled unless needed for remote admin tools.
Alternatives include the built-in Steam host functionality, tModLoader server for modded play, and commercial game server hosts. Self-hosting with TShock gives the most admin control and plugin flexibility.
Avoid self-hosting if you only need occasional 2-player sessions — the built-in Steam friend join system works fine without a dedicated server. Also avoid if server version management is too complex for your comfort level.
PrismaTechWork provides end-to-end infrastructure services — from initial deployment and security hardening to ongoing monitoring, automated backups, and dedicated support. Whether you need a single-server setup or a multi-site network, our team ensures your infrastructure is built right, secured properly, and maintained reliably.
TShock is a Terraria server plugin platform that adds admin commands, permissions, region protection, anti-cheat, and REST API support. Most dedicated Terraria server admins use TShock instead of vanilla because of its extensive admin tools. If you need to manage a community or multi-player server, TShock is highly recommended.
Yes. Copy your .wld world file from your local Terraria worlds folder (usually in Documents/My Games/Terraria/Worlds) to the server's worlds directory. Edit serverconfig.txt to point to the world file name and the server will load your existing world.
The Terraria server supports up to 255 players simultaneously, though performance degrades significantly above 20 to 30 players for most hardware. For a friend group of 5 to 10 players, any modern server with 2 GB RAM handles it easily.
Yes. Terraria mods use tModLoader, a separate mod-enabled version of the game available on Steam. To run modded multiplayer, install tModLoader server (separate from vanilla) and place mod files in the Mods directory. All connecting players must also have the same mods installed via tModLoader.
Install TShock and use the region protection feature. Define rectangular regions over base areas and assign build permissions to specific players or groups. Players outside the allowed list cannot place or break blocks within protected regions, preventing unauthorized modification.
With TShock, authenticate as admin in-game and use commands like /kick, /ban, /give, /time, and /tp. The full list is available in the TShock documentation. TShock also provides a REST API for remote server management via web requests.
serverconfig.txt is the Terraria server configuration file where you define the world path, max players, server password, server port, and other settings. Create one and pass it to the server startup with the -config serverconfig.txt flag. This avoids manual interactive setup on each restart.
Use Docker Compose with the restart: always policy to keep the server running as a background service. Alternatively, use tmux or screen to detach the server process, or create a systemd service unit. The Docker-based setup handles this automatically.