Get your free server today! View Plans →
Home Plans Blog About Contact Panel Join Discord
Game Servers

How to set up a Terraria dedicated server

A friendly walkthrough for hosting your own Terraria server so friends can join any time. Covers vanilla setup, TShock, running it headless, and backups.

How to set up a Terraria dedicated server

By the end of this guide you'll have a Terraria dedicated server running on a Linux box, with a saved world your friends can join at any time, even when you've closed the game on your own machine. We'll cover both the plain vanilla server and TShock, which is the popular drop in replacement that adds commands and grief protection. This is written for someone comfortable copying commands into a terminal, but you don't need to be a Linux expert.

Vanilla server or TShock: which one do you need?

Terraria ships with an official dedicated server that comes bundled with the game. It does exactly one job. It loads a world, listens for players, and saves now and then. There's no admin console worth talking about, no way to kick a troublemaker by name, and no easy rollback if someone burns down your base. For a small group of friends who all trust each other, that's completely fine.

TShock is a community built server that runs your same worlds but adds a real management layer on top. You get in game commands, a permission system, regions you can protect from editing, the ability to ban by account or IP, and a long list of admin tools. If you're running anything that's public, or you just want a kick command, go with TShock.

Here's the short version. Pick vanilla if you want the simplest possible setup and you only play with people you know. Pick TShock if you want control. The good news is the world files are compatible, so you can start vanilla and switch later without losing your map.

Step 1: Get the server files onto your machine

The vanilla dedicated server is included in the same download as the game, but you don't need to own a copy on the server itself. Terraria publishes the dedicated server as a separate zip on their site. The exact version number changes over time, so check the current one, but the pattern looks like this. Grab it with wget and unzip it.

cd ~
wget https://terraria.org/api/download/pc-dedicated-server/terraria-server-1449.zip
unzip terraria-server-1449.zip
cd 1449/Linux
chmod +x TerrariaServer.bin.x86_64

That last command marks the binary as executable, which Linux needs before it'll run the file. If you'd rather use TShock instead, skip the download above and grab the latest release from the TShock GitHub releases page. It comes as a single archive you extract into its own folder.

mkdir ~/tshock
cd ~/tshock
wget https://github.com/Pryaxis/TShock/releases/download/v5.2.0/TShock-5.2-for-Terraria-1.4.4.9-linux-x64-Release.zip
unzip TShock-5.2-for-Terraria-1.4.4.9-linux-x64-Release.zip
chmod +x TShock.Server

One thing that catches people out: the TShock version has to match the Terraria game version your players are on. If your friends updated their game and the server didn't, nobody connects. Always read the release notes to confirm the supported game version before you download.

Step 2: Write a serverconfig.txt

You can answer the setup questions by hand every time the server starts, but that gets old fast. The better way is a config file. Create a file called serverconfig.txt next to the server binary and the server will read it on launch with the -config flag. Here's a sensible starting point for vanilla.

world=/home/terraria/.local/share/Terraria/Worlds/mainworld.wld
autocreate=3
worldname=MainWorld
difficulty=1
maxplayers=8
port=7777
password=changeme
motd=Welcome to the server. Be nice.
secure=1
language=en-US

A few of those lines do the heavy lifting, so here's what they mean.

For TShock the config file is the same idea but TShock keeps most of its own settings in a JSON file (more on that later). You can still pass a serverconfig.txt to control the world, port, and player count.

Step 3: Run it once by hand

Before you set up anything fancy, run the server directly so you can see it work and catch errors early. From the folder with the binary:

./TerrariaServer.bin.x86_64 -config serverconfig.txt

If everything's right you'll see it load or create the world, then print a line like this:

Terraria Server v1.4.4.9
Listening on port 7777
Type 'help' for a list of commands.: Server started

That colon at the start of the line is the server console prompt. You can type commands here. playing shows who's connected, save forces a world save, and exit shuts the server down cleanly. Always use exit rather than just closing the window, because that's what guarantees your world gets written to disk before the process ends.

For TShock the command is slightly different, and the first launch walks you through creating a superadmin account in game using the /setup code it prints.

./TShock.Server -config serverconfig.txt

Step 4: Keep it running headless with screen or systemd

The problem with running it by hand is that the moment you close your SSH session, the server dies with it. You need it to keep running in the background. There are two common ways to do this.

Option A: the quick way with screen

The screen tool gives you a terminal session that survives after you disconnect. Install it, start a named session, launch the server inside it, then detach.

sudo apt install screen
screen -S terraria./TerrariaServer.bin.x86_64 -config serverconfig.txt

Once it's running, press Ctrl+A then D to detach. The server keeps going. To come back and type console commands later, run screen -r terraria. This is great for testing and small setups. The downside is the server won't restart itself if the machine reboots or the process crashes.

Option B: the proper way with systemd

For anything you care about, a systemd service is better. It starts the server on boot and restarts it automatically if it falls over. Create a file at /etc/systemd/system/terraria.service with the following.

[Unit]
Description=Terraria Dedicated Server
After=network.target

[Service]
Type=simple
User=terraria
WorkingDirectory=/home/terraria/1449/Linux
ExecStart=/home/terraria/1449/Linux/TerrariaServer.bin.x86_64 -config /home/terraria/1449/Linux/serverconfig.txt
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Then load it, enable it so it survives reboots, and start it.

sudo systemctl daemon-reload
sudo systemctl enable terraria
sudo systemctl start terraria
sudo systemctl status terraria

The status command should show active (running) in green. To read the console output and watch what the server is doing, use the journal.

journalctl -u terraria -f

One catch with systemd: because there's no interactive console attached, you can't type save or exit directly. This is one of the reasons people lean toward TShock, which lets admins run commands from inside the game instead.

Step 5: Where world files live and how to load a specific one

On Linux, Terraria stores worlds in a hidden folder under your home directory. The default location is:

~/.local/share/Terraria/Worlds/

Each world is a .wld file, and there's usually a matching .wld.bak backup that Terraria writes automatically. If you made a world on your own PC and want to host it, just copy the .wld file into that folder on the server, then point the world= line in your config at it. You can list what's there to confirm.

ls -lh ~/.local/share/Terraria/Worlds/
-rw-r--r-- 1 terraria terraria  12M Jun 20 14:03 mainworld.wld
-rw-r--r-- 1 terraria terraria  12M Jun 19 21:11 mainworld.wld.bak

To load a different world, change the path in serverconfig.txt and restart the service. The server always loads whatever the world= line points to, so swapping maps is just a matter of editing that one line.

Step 6: Open the port so players can connect

Your server listens on port 7777 by default, and that traffic is TCP. If there's a firewall on the box, you need to let that port through. With UFW on Ubuntu or Debian:

sudo ufw allow 7777/tcp
sudo ufw reload

If your server is at home behind a router, you'll also need to forward port 7777 to the machine's local IP in your router settings, and you'll share your public IP with friends. On a VPS the public IP is already directly reachable, so the firewall rule above is usually all you need. To join, players open Terraria, pick Multiplayer, then Join via IP, and type your address. If the port isn't the default they add a colon and the port number.

Step 7: What TShock adds, and how to set it up

If you went with TShock, the real power lives in its config and command system. After the first run, TShock creates a folder called tshock with a file named config.json inside. That's where you tune things like spawn protection, server name, and whether a server password is required.

The first time a player joins, they register an account with /register in the chat. To make yourself the boss, you use the auth code TShock printed on first launch.

/login yourname yourpassword
/user group yourname superadmin

Once you're a superadmin, you have a big toolbox. A few commands you'll use constantly:

That permission and region system is the whole reason TShock exists. On a public server it's the difference between a map that lasts and one that gets wrecked in a weekend.

Step 8: Back up your worlds

Worlds get corrupted. People grief. Disks fail. A backup takes seconds and saves hours of heartbreak. The simplest approach is a small script that copies the Worlds folder somewhere safe with a date stamp.

#!/bin/bash
SRC="/home/terraria/.local/share/Terraria/Worlds"
DEST="/home/terraria/backups"
STAMP=$(date +%Y-%m-%d_%H-%M)
mkdir -p "$DEST"
tar -czf "$DEST/worlds-$STAMP.tar.gz" -C "$SRC".
echo "Backup written to $DEST/worlds-$STAMP.tar.gz"

Save that as backup.sh, make it executable with chmod +x backup.sh, and you can run it any time. To run it automatically every night at 4am, add a cron entry with crontab -e:

0 4 * * * /home/terraria/backup.sh

For extra safety, copy those archives off the server now and then, to another machine or to object storage. A backup that lives only on the same disk as the original doesn't help when that disk dies. Most managed game hosts, including the panel we run at Bytte.cloud, can snapshot or schedule backups for you, but a cron script like this works anywhere.

Troubleshooting

Players cannot connect at all. Nine times out of ten this is the port. Confirm the server is actually listening with ss -tlnp | grep 7777. If nothing shows up, the server isn't running or it crashed on startup, so check the logs. If it is listening locally but friends still can't join, the firewall or your router port forward is the culprit. Terraria multiplayer uses TCP on 7777, not UDP, so make sure the rule matches.

The world won't load. Double check the path in your world= line is exactly right, including the .wld extension and the correct capitalization. Linux paths are case sensitive, so Worlds and worlds are different folders. Also check the file is owned by the user the server runs as. If the service runs as terraria but the file is owned by root, the server can't read it. Fix ownership with sudo chown terraria:terraria mainworld.wld.

It says the password is incorrect. The server password in your config and the one your players type have to match exactly, and it's case sensitive. If you left the example value in place, change it. After editing the config, restart the server, because it only reads the file at launch.

TShock and the client disagree on version. If TShock refuses connections or players get kicked at the loading screen, the TShock build doesn't match the Terraria game version. Update both ends so the game version lines up with what your TShock release supports.

The world didn't save after a crash. If you were running under systemd or screen and the process died hard, you may lose progress since the last autosave. This is why the .bak file exists. Rename it from mainworld.wld.bak to mainworld.wld to roll back to the previous save. And it's why those scheduled backups matter.

Wrapping up

You now have a Terraria server that loads a world, lets your friends in over the network, keeps running after you log out, and gets backed up on a schedule. Start with vanilla if you just want to play, and move to TShock the moment you need to manage people or protect builds. Keep the game version, the server version, and your players all in sync, watch the logs when something acts up, and test a connection yourself before you hand out the IP. From here you can tweak difficulty, grow the player cap, or layer on TShock regions and permissions as your group gets bigger.

Common questions

Should I run a vanilla Terraria server or TShock?

Use vanilla if you only play with people you trust and want the simplest setup. Use TShock if you need admin commands, bans, permissions, or region grief protection. World files work in both, so you can switch later without losing your map.

What port does a Terraria server use?

Terraria multiplayer uses TCP port 7777 by default. Open it in your firewall, and if you host from home, forward 7777 to the machine on your router. Note it is TCP, not UDP.

Where are Terraria world files stored on Linux?

They live in ~/.local/share/Terraria/Worlds/ as.wld files, each with a matching.wld.bak backup. To host an existing world, copy the.wld file there and point the world= line in serverconfig.txt at it.

How do I keep a Terraria server running after I log out?

Use screen for a quick session that survives disconnecting, or a systemd service for a setup that starts on boot and restarts after a crash. Systemd is the more reliable choice for anything you care about.

How do I back up a Terraria world?

Copy the Worlds folder somewhere safe, ideally with a dated tar.gz archive run on a nightly cron job. Keep at least one copy off the server, since a backup on the same disk does not help when that disk fails.

TR
Tom Reyes
Support Engineer at Bytte.cloud

Part of the Bytte.cloud team. We run game servers, bots and websites for a living, and we write these guides from what we see day to day in support and on our own servers.

Want to try this on real hardware?

Bytte.cloud has free plans for game servers, bots and websites. No credit card, set up in seconds.

Start for free See the plans