
Terraria server
Run a Terraria dedicated server with LinuxGSM, in Docker or directly on Linux.
Run with Docker
First install Docker Engine and the Compose plugin on your Linux host. Run the commands below from your project directory with a user allowed to access Docker; otherwise prefix Docker commands with sudo. The container manages its own linuxgsm user.
The terraria image has LinuxGSM and every dependency for Terraria already installed on Ubuntu 26.04. On first start it downloads the game server, then keeps it updated.
1. Create compose.yaml
services:
terrariaserver:
image: ghcr.io/gameservermanagers/gameserver:terraria
container_name: terrariaserver
restart: unless-stopped
network_mode: host
volumes:
- ./terrariaserver:/data
environment:
- UPDATE_CHECK=60Also published on Docker Hub as gameservermanagers/gameserver:terraria. Prefer docker run? See Docker help.
2. Add your Steam login before the first start
Create the LinuxGSM config file inside the data directory. LinuxGSM reads it on first start and keeps it on updates.
mkdir -p terrariaserver/config-lgsm/terrariaserver
nano terrariaserver/config-lgsm/terrariaserver/common.cfgsteamuser="username"
steampass='password'3. Start it
docker compose up -d
docker compose logs -fThe first start installs the server, which can take a while for large games. When it is ready the log shows the server details, including ports and passwords.
Ports
With network_mode: host the server uses the host's ports directly, so there is nothing to map. Open them in your firewall.
| Purpose | Default port | Protocol | Setting |
|---|---|---|---|
| Game | 7777 | TCP | port |
| Query | 7777 | TCP | queryport |
Defaults from LinuxGSM and the game's own config. Ports you change in your config will differ: run details to see the ones in use.
Manage the server
- Show details, ports and passwords
docker exec -it --user linuxgsm terrariaserver ./terrariaserver details- Open the live console (leave with CTRL+b then d)
docker exec -it --user linuxgsm terrariaserver ./terrariaserver console- Restart the game server
docker restart terrariaserver- Check for a game update now
docker exec -it --user linuxgsm terrariaserver ./terrariaserver update- Update the image
docker compose pull && docker compose up -d
Server files, configs and logs live in ./terrariaserver on the host: back up that directory. Docker help below covers permissions, environment variables and bridge networking.
Docker help
Images and tags
Images are built weekly and published to two registries. They are identical, so use whichever you prefer.
| Registry | Image |
|---|---|
| GitHub Container Registry | ghcr.io/gameservermanagers/gameserver:terraria |
| Docker Hub | gameservermanagers/gameserver:terraria |
The image uses the base OS LinuxGSM recommends for this game. You do not need to match it on the host.
Use docker run instead of Compose
docker run -d \
--name terrariaserver \
--network host \
--restart unless-stopped \
-v "$PWD/terrariaserver:/data" \
-e UPDATE_CHECK=60 \
ghcr.io/gameservermanagers/gameserver:terrariaData and permissions
Everything that should survive a container update lives in /data inside the container, which is ./terrariaserver on the host.
Path in /data | Contents |
|---|---|
serverfiles/ | The game server itself |
config-lgsm/ | LinuxGSM config, including common.cfg |
log/ | Script, console and game logs |
data/ | LinuxGSM data and cache |
The game server runs as the linuxgsm user, not root. On every start the container sets that user to UID and GID (both 1000 by default) and takes ownership of /data. If your host user has a different ID, set them to match so you can edit files on the host:
environment:
- UID=1001
- GID=1001Environment variables
| Variable | Default | What it does |
|---|---|---|
UPDATE_CHECK | 60 | Minutes between update checks, from 1 to 59, or 60 for hourly. 0 turns scheduled checks off. |
UPDATE_ON_START | true | Check for a game update every time the container starts. |
VALIDATE_ON_START | false | Run a SteamCMD validate on start. Slow, but repairs broken files. |
UID / GID | 1000 | User and group IDs the game server runs as. |
LGSM_GITHUBBRANCH | master | LinuxGSM branch to run. Set develop to test unreleased fixes. |
Updates and health checks
The game server updates itself. The container checks every UPDATE_CHECK minutes and on start. If an update is out, it stops the server, updates it and starts it again.
The image brings new LinuxGSM releases, dependency fixes and OS updates. Pull it now and then with docker compose pull && docker compose up -d.
The image runs LinuxGSM's monitor as the Docker health check every minute, so docker ps shows whether the game server is answering, not just whether the container is up.
Bridge networking
network_mode: host is the simplest choice: the game server uses the host's ports directly, the way it would without Docker, and query ports work without extra setup.
If you need bridge networking, publish each port the server uses. Run details to see them, then add them with the right protocol:
ports:
- "PORT:PORT/udp"
- "PORT:PORT/tcp"Bridge networking can hide the server's real IP from the game, which breaks some server browsers. Use host networking if players cannot find the server.
Troubleshooting
- Permission denied in
/data: setUIDandGIDto the owner of the host directory. - Server not listed in game: check the ports are open, use host networking, and add a GSLT if the game needs one.
- Install fails at SteamCMD: the game may need a Steam login. Check the notes at the top of this page.
- Will not start: stop the container, then run
docker compose run --rm terrariaserver debugto see why. - Still stuck: run
detailsanddebug, then ask on Discord or GitHub Discussions with the output.
Install on Linux
Install directly on a server running Ubuntu 26.04, Debian 11 or Enterprise Linux 8.
1. Create a user and log in
Creating users and installing system packages require administrator privileges. From your administrator account, use sudo below (omit it if already root). Install curl, tar and an editor such as nano with your distribution's package manager first.
sudo adduser terrariaserverGive the user a strong password, then switch to its login shell:
sudo su - terrariaserverRun all remaining commands as terrariaserver from its home directory, without sudo. On Enterprise Linux, create the account with sudo useradd -m terrariaserver and set its password with sudo passwd terrariaserver instead of adduser.
2. Download LinuxGSM
curl -Lo linuxgsm.sh https://linuxgsm.sh && chmod +x linuxgsm.sh && bash linuxgsm.sh terrariaserver3. Add your Steam login
Create lgsm/config-lgsm/terrariaserver/common.cfg relative to the game-server user's home directory and add your dedicated Steam account:
mkdir -p lgsm/config-lgsm/terrariaserver
nano lgsm/config-lgsm/terrariaserver/common.cfgsteamuser="username"
steampass='password'4. Install
./terrariaserver installLinuxGSM checks dependencies and installs the game files. If this user has sudo access, it can install missing packages when prompted. Otherwise, ask an administrator to install the packages listed by LinuxGSM, then rerun this command as terrariaserver. Running ./terrariaserver install as root only installs dependencies, not the game server.
5. Configure and start the server
Review your LinuxGSM settings in lgsm/config-lgsm/terrariaserver/terrariaserver.cfg (instance settings) or lgsm/config-lgsm/terrariaserver/common.cfg (shared settings). Do not edit _default.cfg, which LinuxGSM updates automatically. Game settings use a separate config file; run ./terrariaserver details to find its path. Once configured, start the server explicitly:
./terrariaserver startCommon commands
- Start the server
- start
./terrariaserver start - Stop the server
- stop
./terrariaserver stop - Restart the server
- restart
./terrariaserver restart - Show details, ports and passwords
./terrariaserver details- Open the live console (leave with CTRL+b then d; CTRL+c stops the server)
./terrariaserver console- Update the game server
./terrariaserver update- Run in the foreground to debug
./terrariaserver debug- Back up the whole server
./terrariaserver backup- List every command
./terrariaserver
Automate with cron
Restart the server if it crashes, apply game updates and keep LinuxGSM current. Add these with crontab -e.
*/5 * * * * /home/terrariaserver/terrariaserver monitor > /dev/null 2>&1
*/30 * * * * /home/terrariaserver/terrariaserver update > /dev/null 2>&1
0 0 * * 0 /home/terrariaserver/terrariaserver update-lgsm > /dev/null 2>&1Deploy from a cloud marketplace
LinuxGSM is available as a one-click app on two cloud providers. You get a fresh Ubuntu server with LinuxGSM ready to use, then install Terraria on it.
Akamai (Linode) Marketplace
- Open LinuxGSM on the Akamai Marketplace and start a deploy.
- Choose a limited sudo username and, under the advanced options, set the game server name to
terrariaserver. - Pick any plan with enough CPU, memory and disk for Terraria, then create the instance.
- When it has finished setting up, log in over SSH or the Lish console and read the generated passwords, then switch to the
linuxgsmuser and install:
cat /home/YOUR_USERNAME/.credentials
su linuxgsm
cd /home/linuxgsm
./terrariaserver installAkamai does not keep this app updated for you, so run ./terrariaserver update-lgsm now and then. Details are in the Akamai guide.
DigitalOcean Marketplace
Create a Droplet from the LinuxGSM 1-Click App, choosing a size with enough resources for Terraria. Log in over SSH and follow the Linux install steps for terrariaserver.
Remember to open the game's ports in the provider's cloud firewall as well as on the server.