--- title: "How to Set Up a Terraria Server on Ubuntu 24.04" description: "Install the official Terraria dedicated server on Ubuntu 24.04, configure the world and password, run it with systemd and tmux, and back up your worlds." category: "Game Servers" language: en source: https://cubepath.com/docs/game-servers/terraria-server-installation-on-linux updated: 2026-09-25 --- # How to Set Up a Terraria Server on Ubuntu 24.04 Terraria's developer, Re-Logic, publishes a free dedicated server for Linux that lets your friends play in a shared world whether or not you are online. In this tutorial you will install the official Terraria server on Ubuntu 24.04, create a world from a configuration file, run the server as a systemd service inside a `tmux` session so you can still use its console, open the firewall and schedule world backups. ## Prerequisites To follow this guide you need: - A server running Ubuntu 24.04 LTS (x86_64), for example a CubePath VPS. 1 CPU core and 2 GB of RAM are enough for a small group on a medium world; large worlds with many players need more memory. - A non-root user with `sudo` privileges. - A PC copy of Terraria on the same version as the server you download. ## Step 1 - Installing the required packages The server is distributed as a ZIP file, and you will use `tmux` to keep its interactive console available while it runs in the background: ```bash sudo apt update sudo apt install unzip tmux ``` ## Step 2 - Creating a dedicated user Run the server under its own unprivileged account, never as root: ```bash sudo useradd -m -s /bin/bash terraria sudo -iu terraria ``` The rest of this step and the next one run as the `terraria` user. ## Step 3 - Downloading the Terraria server Open [terraria.org](https://terraria.org), scroll to the bottom of the page and copy the link of the **PC Dedicated Server** download. The file name contains the game version without dots, for example `terraria-server-1449.zip` for version 1.4.4.9. Use the link for the version your players run: ```bash wget -O terraria-server.zip "https://terraria.org/api/download/pc-dedicated-server/terraria-server-1449.zip" unzip terraria-server.zip ``` The archive contains a directory named after the version with Windows, Mac and Linux builds. Move the Linux build to a stable path so future updates only replace that directory: ```bash mv 1449/Linux ~/server rm -rf 1449 terraria-server.zip chmod +x ~/server/TerrariaServer.bin.x86_64 ls ~/server ``` You should see `TerrariaServer.bin.x86_64` together with its libraries. ## Step 4 - Writing the server configuration Without a configuration file the server asks interactive questions on every start. A config file makes it start unattended and creates the world automatically the first time. Create a directory for worlds and open a new config file: ```bash mkdir -p ~/worlds nano ~/serverconfig.txt ``` ```ini world=/home/terraria/worlds/CubePath.wld autocreate=2 worldname=CubePath difficulty=0 maxplayers=8 port=7777 password=your_server_password motd=Welcome to the CubePath Terraria server worldpath=/home/terraria/worlds banlist=/home/terraria/banlist.txt secure=1 upnp=0 ``` The keys that matter most: | Key | Meaning | |---|---| | `world` | Full path of the world file to load. | | `autocreate` | If `world` does not exist, create it with this size: `1` small, `2` medium, `3` large. | | `worldname` | Name given to a newly created world. | | `difficulty` | For new worlds: `0` classic, `1` expert, `2` master, `3` journey. | | `password` | Password players must enter. Leave it out for an open server. | | `secure` | `1` enables the built-in cheat protection. | | `upnp` | `0` disables automatic port forwarding, which is pointless on a server with a public IP. | Leave the `terraria` user when you are done: ```bash exit ``` ## Step 5 - Running the server with systemd and tmux The vanilla Terraria server expects an interactive console and does not behave well without one. The common solution is to start it inside a detached `tmux` session and let systemd manage that session. You get automatic start at boot and restart on failure, and you can still attach to the console to run commands. Create the unit file: ```bash sudo nano /etc/systemd/system/terraria.service ``` ```ini [Unit] Description=Terraria dedicated server Wants=network-online.target After=network-online.target [Service] Type=forking User=terraria Group=terraria WorkingDirectory=/home/terraria/server ExecStart=/usr/bin/tmux new-session -d -s terraria /home/terraria/server/TerrariaServer.bin.x86_64 -config /home/terraria/serverconfig.txt ExecStop=/bin/sh -c '/usr/bin/tmux send-keys -t terraria exit Enter; while /usr/bin/tmux has-session -t terraria 2>/dev/null; do sleep 1; done' TimeoutStopSec=90 Restart=on-failure RestartSec=10 [Install] WantedBy=multi-user.target ``` `ExecStop` types `exit` into the server console, which saves the world and shuts down cleanly, then waits until the session is gone before systemd considers the service stopped. Start the service and enable it at boot: ```bash sudo systemctl daemon-reload sudo systemctl enable --now terraria sudo systemctl status terraria --no-pager ``` The first start generates the world, which takes a minute or more for a medium or large map. ## Step 6 - Using the server console Attach to the console as the `terraria` user: ```bash sudo -u terraria tmux attach -t terraria ``` When the world has loaded you will see: ```output Listening on port 7777 Type 'help' for a list of commands. : Server started ``` Useful console commands are `help`, `playing` (list connected players), `save`, `kick `, `ban `, `say ` and `motd`. To leave the console without stopping the server, detach from tmux with `CTRL+B` and then `D`. Do not type `exit` unless you want to stop the server, and do not press `CTRL+C`. Confirm from your normal shell that the server is listening: ```bash sudo ss -tlnp | grep 7777 ``` ```output LISTEN 0 ... 0.0.0.0:7777 0.0.0.0:* users:(("TerrariaServer.",pid=...,fd=...)) ``` ## Step 7 - Opening the firewall Terraria uses a single TCP port, 7777 by default. If UFW is enabled, allow it: ```bash sudo ufw allow 7777/tcp ``` In Terraria, choose **Multiplayer**, then **Join via IP**, pick a character, enter `your_server_ip` and port `7777`, and type the password from `serverconfig.txt`. ## Step 8 - Backing up worlds A Terraria world is the `.wld` file in `/home/terraria/worlds`, plus `.wld.bak` backups the game keeps next to it. The server saves automatically, but copies on the same disk do not protect you from disk failure or a corrupted save. Create a backup directory and schedule a nightly archive at 05:00 for the `terraria` user, keeping 14 days: ```bash sudo -u terraria mkdir -p /home/terraria/backups sudo -u terraria crontab -e ``` ```text 0 5 * * * tar -czf /home/terraria/backups/worlds-$(date +\%F).tar.gz -C /home/terraria worlds && find /home/terraria/backups -name 'worlds-*.tar.gz' -mtime +14 -delete ``` The `%` is escaped because cron treats a bare `%` as a newline. Copy the `backups` directory to another machine or to object storage on a regular basis. ## Step 9 - Updating the server When a new Terraria version is released, clients on the new version cannot join an old server. Stop the service, download the new ZIP as in Step 3, and replace only the `server` directory; your config and worlds live outside it: ```bash sudo systemctl stop terraria sudo -iu terraria ``` ```bash wget -O terraria-server.zip "https://terraria.org/api/download/pc-dedicated-server/terraria-server-NEWVERSION.zip" unzip terraria-server.zip rm -rf ~/server mv NEWVERSION/Linux ~/server chmod +x ~/server/TerrariaServer.bin.x86_64 rm -rf NEWVERSION terraria-server.zip exit ``` Replace `NEWVERSION` with the version number in the new download link, then start the server again: ```bash sudo systemctl start terraria ``` ## Troubleshooting - **The service fails to start.** Run `sudo journalctl -u terraria -n 50` and attach to the tmux session if it exists. A wrong path in `world` or `worldpath`, or a missing execute bit on `TerrariaServer.bin.x86_64`, are the usual causes. - **Players get "Lost connection" right after joining.** The client and server versions differ. Update the server as in Step 9. - **The world is not created.** `autocreate` only works together with `world` pointing to a file that does not exist yet and a `worldname`. Check all three keys. - **No one can connect from outside.** Make sure TCP 7777 is open in UFW and in any external firewall, and that `port` in the config matches. ## Conclusion You now have the official Terraria dedicated server running on Ubuntu 24.04 under systemd, with an attachable console and nightly world backups. As next steps, you can upload an existing world by copying its `.wld` file into `/home/terraria/worlds` and pointing `world` at it, or switch to TShock, a community server built on the same game code that adds user accounts, permission groups, protected regions and plugins.