SameOS ~/tools/terraria-linux-dedicated-server.md

Building and Operating a Terraria 1.4.5.8 Server on Linux

Published and official references checked 2026-08-29 · SameOS operator

Terraria’s server is lightweight, but a relative world path can bury data inside a replaceable release, a UDP-only firewall rule cannot open its TCP port, and closing the console can skip the intended save path. This guide uses the official 1.4.5.8 Linux build, separates binaries from worlds, and starts repeatably from one configuration file.

Prepare the Official ZIP and Service Account

On 2026-08-29, the official wiki points to server build 1458 for Terraria 1.4.5.8. The URL and extracted directory change with releases, so recheck the wiki Downloads section before installation. The process runs as a dedicated terraria user, never root.

sudo apt update
sudo apt install -y wget unzip
sudo useradd --system --create-home --home-dir /srv/terraria \
  --shell /usr/sbin/nologin terraria
sudo install -d -o terraria -g terraria \
  /srv/terraria/releases /srv/terraria/worlds /srv/terraria/backups

wget -O /tmp/terraria-server-1458.zip \
  'https://terraria.org/api/download/pc-dedicated-server/terraria-server-1458.zip'
sudo -u terraria unzip /tmp/terraria-server-1458.zip \
  -d /srv/terraria/releases
sudo chmod 750 /srv/terraria/releases/1458/Linux/TerrariaServer.bin.x86_64

Pin the World and Port in serverconfig.txt

The interactive wizard can create a first world, but a config file makes reboot behavior reproducible. An absolute world path outside releases prevents a new server ZIP from replacing or hiding the save.

autocreate only applies when the configured world file does not exist. A typo can therefore create a blank world and look like data loss. After the first start, confirm the exact .wld path. Replace the sample join password rather than publishing it unchanged.

# /srv/terraria/serverconfig.txt
world=/srv/terraria/worlds/friends.wld
autocreate=2
worldname=Friends World
difficulty=1
maxplayers=8
port=7777
password=CHANGE_THIS_PASSWORD
motd=Welcome. Ask before changing shared builds.
secure=1
upnp=0
language=en-US
priority=1

Run It Interactively Once

Before systemd, run once as terraria to catch configuration parsing, world creation, and port errors. In the console, save writes the world and exit saves before shutdown. exit-nosave deliberately discards recent changes and is not an operational stop command.

cd /srv/terraria/releases/1458/Linux
sudo -u terraria ./TerrariaServer.bin.x86_64 \
  -config /srv/terraria/serverconfig.txt

# In the Terraria console
save
exit

ls -lh /srv/terraria/worlds/friends.wld

systemd and TCP 7777

Terraria listens on TCP 7777 by default. Join over the LAN first, and open the same TCP port on the router and host only when external friends need it. Keeping UPnP off leaves one explicit rule to inspect.

Prove that SIGINT saves the current build with a disposable world before trusting automatic service stops. If journalctl lacks a completed save or the world modification time does not move, do not back up after that stop; use the interactive save then exit sequence instead.

# /etc/systemd/system/terraria.service
[Unit]
Description=Terraria Dedicated Server
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=terraria
Group=terraria
WorkingDirectory=/srv/terraria/releases/1458/Linux
ExecStart=/srv/terraria/releases/1458/Linux/TerrariaServer.bin.x86_64 \
  -config /srv/terraria/serverconfig.txt
KillSignal=SIGINT
TimeoutStopSec=90
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

sudo systemctl daemon-reload
sudo systemctl enable --now terraria
sudo journalctl -u terraria -n 100 --no-pager
sudo ss -ltnp | grep ':7777'
sudo ufw allow 7777/tcp

Back Up Worlds After a Proven Stop

With worlds isolated under /srv/terraria/worlds, archive that directory and serverconfig.txt only after a verified clean stop. Do not rely only on one .wld.bak; retain dated archives and a copy on another device. The config contains the join password, so its backup must stay outside public downloads.

sudo systemctl stop terraria
sudo -u terraria tar -C /srv/terraria -czf \
  /srv/terraria/backups/terraria-$(date +%F-%H%M).tar.gz \
  worlds serverconfig.txt
sudo systemctl start terraria

gzip -t /srv/terraria/backups/terraria-YYYY-MM-DD-HHMM.tar.gz
tar -tzf /srv/terraria/backups/terraria-YYYY-MM-DD-HHMM.tar.gz

Moving to a New Release

Verification scope and official references

The official Terraria Wiki was checked for the 1.4.5.8 server download, Linux x86_64 binary, default TCP 7777, world path, and console save commands. Recheck the official link when the build changes. No production world was used.

Read the SameOS writing, translation, and review policy

Game server restore drill Valheim Linux server Minecraft Bedrock Linux server