Video coming soon…

🌿 Setup Terraria Server — 2D Sandbox Multiplayer

Dedicated Terraria server for 2D sandbox adventure with friends — host a persistent world with optional TShock modded server management.

⚠️ This script is provided for demo and testing purposes only. Not intended for production use.

📦 Resources & Setup Scripts

Grab the automated bash script from GitHub to follow along with the video.

Automated install script — your Terraria world running 24/7 in one command.
View on GitHub

Quick Install:

wget https://raw.githubusercontent.com/mhmdali94/Docker/main/gaming/terraria/terraria-ubuntu.sh
chmod +x terraria-ubuntu.sh
sudo bash terraria-ubuntu.sh

Tutorial Steps

1 Download & Run Installer

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

2 Configure Server

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

3 Connect with Game Client

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

4 Manage World

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

Ports Used

PortPurpose
7777 (TCP)Game traffic

Overview

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.

Why Use It

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.

When You Need It

    Who Should Use It

      Real Use Cases

        Main Features

          How to Use After Installation

            Security Best Practices

              Ports and Firewall Notes

              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.

              Backup and Maintenance

                Common Mistakes

                  Troubleshooting

                    Alternatives

                    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.

                    When Not to Use It

                    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 Professional Help

                    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.

                      Contact Us

                      Frequently Asked Questions

                      What is TShock and should I use it?

                      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.

                      Can I transfer my existing Terraria world to the server?

                      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.

                      How many players can a Terraria server support?

                      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.

                      Does Terraria have mods and can the server run them?

                      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.

                      How do I protect base areas from griefing?

                      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.

                      Can I run commands as an admin?

                      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.

                      What is the serverconfig.txt file?

                      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.

                      How do I keep the server running after I close the terminal?

                      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.