Terraria Field guide

How to set up a Terraria server on Ubuntu 24.04

Install a Terraria 1.4.5.8 PC server on Ubuntu, select its world, allow TCP7777 and preserve data with console shutdown and off-VPS backups.

How to set up a Terraria server on Ubuntu 24.04

Run the vanilla PC server under its own Linux account, select one world explicitly and preserve that world through restarts. This guide uses Ubuntu 24.04 x86_64 and Terraria 1.4.5.8, with direct-IP connections. tModLoader, TShock and crossplay need separate compatibility checks.

Use a fresh VPS with a public IPv4 address, SSH and sudo. Reserve several gigabytes of RAM for a small vanilla group and check actual use while generating the world; this is a starting allocation, not a player-capacity guarantee. Keep your provider's recovery console available before changing the firewall.

Download the matching PC server#

Check every player's complete version number first. The official 1.4.5.8 archive contains a 1458/Linux directory, its launcher and bundled runtime files. If clients use a different release, select the corresponding server from Terraria's website; do not change digits in a download address by guesswork.

Run from your normal SSH account:

bash
sudo apt update
sudo apt install -y curl unzip tmux ufw nano file binutils
sudo useradd --system --user-group --create-home \
  --home-dir /srv/terraria --shell /bin/bash terraria
sudo install -d -o terraria -g terraria -m 750 \
  /srv/terraria/worlds /srv/terraria/backups
curl --fail --location \
  https://terraria.org/api/download/pc-dedicated-server/terraria-server-1458.zip \
  --output /tmp/terraria-server-1458.zip
sha256sum /tmp/terraria-server-1458.zip
sudo unzip -q /tmp/terraria-server-1458.zip -d /opt/terraria-release
sudo chmod +x /opt/terraria-release/1458/Linux/TerrariaServer \
  /opt/terraria-release/1458/Linux/TerrariaServer.bin.x86_64
file /opt/terraria-release/1458/Linux/TerrariaServer.bin.x86_64

The final command identifies the architecture; it does not launch the game. Keep the whole Linux directory together. Copying only its binary loses supporting files. The supplied TerrariaServer launcher enters its own directory and sets the runtime environment, so use it below. Do not install a random system Mono or .NET version to repair a package that has not been checked yet.

Create the world in an interactive console#

The game executable is replaceable. The selected world and stopped-server backups are the data to preserve.

The account's home is /srv/terraria. Start an interactive session under that account:

bash
sudo -iu terraria
umask 077
cd /opt/terraria-release/1458/Linux
tmux new-session -s terraria
./TerrariaServer -worldpath /srv/terraria/worlds

At the server prompts, create a new world, select its size and difficulty and name it Coop. Select that world, allow up to eight players, use port 7777, decline automatic router forwarding and set a nonempty server password. These are example choices for a private group; a Journey world also needs compatible player characters.

Wait for generation to finish and check the displayed game version. Type help to inspect the console commands offered by this build. Then type save, wait for the save to complete and type exit to save and stop. This is the server console, not Bash. Avoid exit-nosave for ordinary shutdowns; the server command reference distinguishes the two commands.

After the process exits, inspect the actual filename:

bash
find /srv/terraria/worlds -maxdepth 1 -type f -name '*.wld' -print
nano /srv/terraria/serverconfig.txt

Use the filename shown, including capitalization. If it is Coop.wld, enter:

ini
world=/srv/terraria/worlds/Coop.wld
worldpath=/srv/terraria/worlds
maxplayers=8
port=7777
password=REPLACE_WITH_A_PRIVATE_PASSWORD
upnp=0

Replace the password placeholder before starting. The archive's Windows/serverconfig.txt documents these shared options. Do not leave autocreate enabled for this existing world: a misspelled path should lead you to repair the selection, rather than accidentally creating a replacement world. Protect the configuration:

bash
chmod 600 /srv/terraria/serverconfig.txt
./TerrariaServer -config /srv/terraria/serverconfig.txt

Detach with Ctrl+B, then D. That keeps the console running after SSH disconnects. From the original administrative SSH account, you can return later with:

bash
sudo -iu terraria tmux attach-session -t terraria

Tmux survives a disconnected terminal; it does not restart the server after a VPS reboot. After a reboot, create a new tmux session as terraria, change into the same Linux directory and launch the same configuration. Never run a second instance against the same world.

Allow access and verify a real join#

Run firewall commands from your normal administrative SSH account. Check the actual SSH port with sudo sshd -T and allow it before enabling UFW. The example assumes SSH is on TCP 22:

bash
sudo ufw allow 22/tcp
sudo ufw allow 7777/tcp
sudo ufw enable
sudo ufw status verbose
sudo ss -ltnp 'sport = :7777'

If your SSH port differs, replace 22 first. Add TCP 7777 to the VPS provider's firewall too. A private-network deployment also needs a router rule pointing to the server's private address. Opening UDP alone will not make this direct TCP connection work.

In the matching PC client, choose Multiplayer → Join via IP, enter the VPS public IPv4 address, port 7777 and the game password. The exact localized menu text may differ. A listening socket proves the local process has bound a port; a successful character entering the correct world proves more. After joining, make a recognizable change, save, restart with exit and confirm that change remains.

Keep a recoverable copy outside the VPS#

Warn players, enter save, wait and enter exit in the attached server console. Wait for the launcher to return to Bash before copying data. While still logged in as terraria:

bash
(
  set -e
  umask 077
  terraria_backup="/srv/terraria/backups/terraria-$(date -u +%Y%m%dT%H%M%SZ).tar.gz"
  tar -czf "$terraria_backup" -C /srv/terraria worlds serverconfig.txt
  tar -tzf "$terraria_backup"
)

Copy the entire worlds directory, including .bak or other rolling world copies that exist. A backup beside the world is useful for a bad edit but disappears with the same failed disk. In a separate administrative SSH session, enter the exact archive path, then stage an owner-only copy in your SSH account’s home:

bash
read -r -p "Exact archive path: " game_archive
ssh_admin=$(id -un)
ssh_group=$(id -gn)
ssh_home=$(getent passwd "$ssh_admin" | cut -d: -f6)
sudo install -o "$ssh_admin" -g "$ssh_group" -m 600 \
  "$game_archive" "$ssh_home/terraria-export.tar.gz"

From your workstation, replace both placeholders:

bash
scp YOUR_SSH_USER@YOUR_VPS_IP:terraria-export.tar.gz .

The staged archive is readable only by its owner. Remove the staged copy after transferring and verifying it; keep your off-VPS backup protected because it contains the server password.

For a restore, stop the server, retain the current world separately and extract the backup into a temporary directory first. Copy its selected world and configuration back as terraria:terraria; start the matching release and verify the recognizable change in a client. Listing the archive alone does not prove restoration.

Diagnose the first failing layer#

ObservationNext checkMeaning
Launcher exits immediatelyRun it interactively from its own directory and retain the complete errorPackaging, permissions or runtime failure occurs before networking
Console reports a version mismatchCompare exact client and server versionsFirewall edits cannot resolve incompatible builds
Server asks to create a world unexpectedlyInspect world= and its exact filenameWrong path or account may select a different save
Socket exists but off-VPS join failsCheck provider firewall and public addressA local listener does not verify the external route
World loses recent changesReview whether shutdown used exit and restore a stopped copyKilling the process is not a verified save operation

Old Linux guides often combine server boot, automatic generation and service shutdown in one step. Starting once interactively separates those failures and gives you an explicit world to preserve. The next improvement is a supervised service whose stop action actually sends the game's save-and-exit command; validate that workflow with a disposable world before trusting it with this one.