Prerequisites & VPS Selection
Terraria is a popular 2D sandbox adventure game that supports multiplayer gameplay through dedicated servers. This guide will walk you through deploying a Terraria dedicated server with full control.
Before starting, ensure you have:
- Ubuntu 22.04 LTS or Debian 12
- SSH root or sudo access to your VPS
- Basic command-line knowledge
Initial Server Setup
Connect to your VPS via SSH and update the system:
apt update && apt upgrade -yapt install -y wget unzip screen tmux nanoCreate a Dedicated User
Create a dedicated user for running the server (security best practice):
useradd -m -s /bin/bash terraria
passwd terrariaDownload and Install Terraria Server
Switch to the terraria user and download the server files:
su - terrariamkdir -p ~/terraria-server
cd ~/terraria-serverwget https://terraria.org/api/download/pc-dedicated-server/terraria-server-1449.zipunzip terraria-server-1449.zip
cd 1449/Linux/
chmod +x TerrariaServer.bin.x86_64💡 Tip: Check the official Terraria website for the latest server version number and update the download URL accordingly.
Configure the Server
Create a server configuration file:
nano serverconfig.txt# Server configuration
world=/home/terraria/terraria-server/Worlds/MyWorld.wld
autocreate=2
# World size: 1=small, 2=medium, 3=large
worldname=MyWorld
difficulty=1
# Difficulty: 0=Classic, 1=Expert, 2=Master, 3=Journey
maxplayers=8
port=7777
password=YourSecurePassword
# Server messages
motd=Welcome to my Terraria server!
# World settings
seed=
worldrollbackstokeep=2
# Network settings
npcstream=60
priority=1
# Security
secure=1
# Language
language=en-USmkdir -p /home/terraria/terraria-server/Worlds⚠️ Important: Replace 'YourSecurePassword' with a strong, unique password for your server!
Configure Firewall
Exit back to root user (Ctrl+D) and configure firewall rules:
ufw allow 7777/tcp
ufw allow 7777/udp
ufw reloadAlternative: Using iptables
iptables -A INPUT -p tcp --dport 7777 -j ACCEPT
iptables -A INPUT -p udp --dport 7777 -j ACCEPT
iptables-save > /etc/iptables/rules.v4Create Startup Script
Switch back to terraria user and create a startup script:
su - terraria
nano ~/start-terraria.sh#!/bin/bash
cd /home/terraria/terraria-server/1449/Linux/
./TerrariaServer.bin.x86_64 -config /home/terraria/terraria-server/serverconfig.txtchmod +x ~/start-terraria.shRunning with Screen (Simple)
# Start a screen session
screen -S terraria
# Run the server
~/start-terraria.sh
# Detach: Press Ctrl+A, then D
# Reattach later:
screen -r terrariaSystemd Service (Recommended)
Create a systemd service for automatic startup and management:
nano /etc/systemd/system/terraria.service[Unit]
Description=Terraria Server
After=network.target
[Service]
Type=simple
User=terraria
WorkingDirectory=/home/terraria/terraria-server/1449/Linux/
ExecStart=/home/terraria/terraria-server/1449/Linux/TerrariaServer.bin.x86_64 -config /home/terraria/terraria-server/serverconfig.txt
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.targetsystemctl daemon-reload
systemctl enable terraria
systemctl start terrariasystemctl status terraria
# View logs
journalctl -u terraria -fServer Management
In-Game Admin Commands
Connect to your server console and use these commands:
help- List all commandsplaying- Show connected playerskick <player>- Kick a player
ban <player>- Ban a playersave- Save the worldexit- Shutdown gracefully
Systemd Management
# Start server
systemctl start terraria
# Stop server
systemctl stop terraria
# Restart server
systemctl restart terraria
# View status
systemctl status terraria
# Enable auto-start on boot
systemctl enable terraria
# Disable auto-start
systemctl disable terrariaPerformance Optimization
Adjust Server Priority
Add to your systemd service for better performance:
Nice=-10
IOSchedulingClass=realtime
IOSchedulingPriority=0Configure Swap Memory
For servers with limited RAM:
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstabMonitor Resources
apt install htop
htopBackup Strategy
Create an automated backup script:
nano /home/terraria/backup-world.sh#!/bin/bash
BACKUP_DIR="/home/terraria/backups"
WORLD_DIR="/home/terraria/terraria-server/Worlds"
DATE=$(date +%Y%m%d_%H%M%S)
mkdir -p $BACKUP_DIR
# Copy world files
cp -r $WORLD_DIR/* $BACKUP_DIR/world_backup_$DATE/
# Keep only last 7 days of backups
find $BACKUP_DIR -type d -mtime +7 -exec rm -rf {} +
echo "Backup completed: $DATE"chmod +x /home/terraria/backup-world.sh
crontab -e
# Add this line for daily backup at 3 AM:
0 3 * * * /home/terraria/backup-world.shAutomatic Restarts
# Daily restart at 4 AM
0 4 * * * systemctl restart terrariaSecurity Hardening
Enable Fail2Ban
apt install fail2ban
nano /etc/fail2ban/jail.local[sshd]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 3
bantime = 3600systemctl restart fail2banSecurity Best Practices
- Use complex server passwords
- Change default SSH port (optional)
- Disable root SSH login after setting up sudo user
Installing TShock (Optional)
TShock adds advanced admin features, permissions, and plugins:
cd /home/terraria
wget https://github.com/Pryaxis/TShock/releases/download/v5.2.0/TShock-5.2-for-Terraria-1.4.4.9.zip
unzip TShock-5.2-for-Terraria-1.4.4.9.zip -d tshock
cd tshock
chmod +x TShock.Server💡 Note: Update your startup script to use TShock.Server instead of the vanilla server executable.
Connecting to Your Server
- Launch Terraria
- Select "Multiplayer"
- Choose "Join via IP"
- Enter:
your-vps-ip:7777 - Enter the server password
