Host terraria server on Linux server
615 Words words, 2 Minutes, 47 Seconds
2024-12-22 00:00 +0000 [04bdc08 @ 2025-05-30]
easiest and simplest way to do this is to run it on docker, because docker is pure magic and there docker image that handles all of what this needs called rathena/terraria.
installing docker
update repos:
sudo apt update
then install docker:
sudo apt install -y docker.io
and enable sysctl:
sudo systemctl enable --now docker
pull and run image
probably making new directory for server configs is a good idea:
mkdir ~/opt/terraria/server1
or something like in games directory what ever you would like just be careful with perditions.
-
pull the image
docker pull rathena/terraria -
run the server
now here there might be some things to modifydocker run -d \ --name=terraria-server \ -p 7777:7777 \ -v ~/opt/terraria/server1:/config \ -e WORLD_NAME="MyWorld" \ -e MAX_PLAYERS=10 \ -e DIFFICULTY=2 \ --restart unless-stopped \ rathena/terraria-
--nameis a name of container this will be used for starting and stopping it if you forget rundocker ps -
-pshows witch ports to forward from container to real machine and7777is a default port for terraria server. if you are running more then one definitely change this. if not this is good. -
-vbinds/configsfolder on container to~/opt/terraria/server1on our server witch we initially crated, if you want to bind it somewhere else just change the~/opt/terraria/server1part to your desired path and again be careful with permeations. -
-emakes environmental variables to configure server and thy are pretty self explanatory.WORD_NAMEspecifies name of the world.MAX_PLAYERSspecifies max player count.DIFFICULTYspecifies difficulty of the game like0: Normal1: Expert2: Master3: Journey Mode change as you wish.
- some other useful environmental variables are:
-e PASSWORD="yourpassword"specifies password for the server-e SEED="worldseed": Specifies a seed for world generation.-e PORT=7777: Sets the server’s port. again if you are running another server change the port witch it runs on here and port forwarded in-pflag
--restart unless-stoppedthis ensures that after power out of restart or shut down server starts automatically if you don’t want that, delete it.- and
rathena/terrariathis you don’t want to change, its a docker image witch container is created from.
-
managing server
now at this point server is running and here are some useful command:
- Stop the server:
docker stop terraria-server - Start the server:
docker start terraria-server - Check logs:
docker logs -f terraria-serverif its called different name check withdocker ps
accessing the server
now for me I’m using tailscale witch is kind like a VPN and works behind CG-NAT witch is my problem too, but its solved and for me and my friend it will work just fine, all they need to do is use my server as they exit node turn the connection on and write in its tailscale IP and then port.
if you are not using tailscale
this is not recommended but you forward your server’s terraria’s port and then share your public IP address to people that want to join and port. this doesn’t work for CG-NAT.
how to forward ports on your router?
And if you are thief and have a cracked version of Terraria (or friend has)
first off all that violates Terraria’s terms of service and if you can you should 100% support the developer and get the real licensed version. allowing cracked users also is a bit risky because those users also bypass security checks.
but if your friend is cheap and won’t buy it :
- locate the
serverconfig.txtfile, for us it will be here~/opt/terraria/server1/serverconfig.txtand open it up with some text editor:nano ~/opt/terraria/server1/serverconfig.txt - and change
ValidateSteam=fromtruetofalse - and restart the container:
docker restart terraria-server
and it should work now for cracked players.