Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Terraria Server Config: Ports and World Settings

· 6 min read · Home Tech

In this article
  1. Where the Config File Lives
  2. Port Settings (The Essential Ones)
  3. World Settings: Generation and Loading
  4. Gameplay and Server Behavior Settings
  5. Common Configuration Mistakes and Fixes
  6. How to Choose the Right Settings for Your Server
  7. Frequently Asked Questions

This guide explains how to configure the ports and world settings in a Terraria server's config.txt file, covering every major option and how to choose values that suit your multiplayer setup. You will learn what each setting does, how to edit the file safely, and how to troubleshoot common connection and world-generation issues.

Where the Config File Lives

Terraria's dedicated server (the TerrariaServer.exe or terraria-server binary) reads a plain-text file named config.txt on startup. On Windows, it sits in the same folder as the server executable. On Linux, it is typically in the directory where you extracted the server files, or in ~/.local/share/Terraria/ if you use the Steam version. If the file does not exist, the server creates one with default values the first time you run it. You can also launch the server with -config <path> to point it at a custom location.

Each line in the file is a key-value pair: setting=value. Lines starting with # are comments and are ignored. The server applies these settings immediately at launch; changing them while the server is running requires a restart.

Port Settings (The Essential Ones)

The two port-related settings control how players connect to your server:

  • port=7777 – The TCP/UDP port the server listens on. The default is 7777. If you change it, players must enter the new port in the client's “Join Server” box (e.g., 123.45.67.89:7778).
  • maxplayers=8 – The maximum number of concurrent players. The valid range is 1 to 255, but the default is 8. Higher values increase CPU and RAM usage, especially during events or with many NPCs.

If you are running a server behind a router, you must forward both TCP and UDP on the chosen port to the server machine's local IP. Terraria uses UDP for gameplay traffic and TCP for the initial handshake and world data transfer. Failing to forward either protocol will cause players to time out or see “Connection Lost.”

World Settings: Generation and Loading

These settings determine which world file the server loads and how new worlds are created:

  • world= – The full path to a .wld file. If left empty, the server will prompt you to select or create a world on first run. Example: world=C:\Terraria\Worlds\MyWorld.wld (Windows) or world=/home/terraria/worlds/MyWorld.wld (Linux).
  • autocreate=1 – If the world path is empty or the file does not exist, this value creates a new world with the given size: 1 = small, 2 = medium, 3 = large. It is ignored if a valid world file is specified.
  • worldname=My World – The name given to a newly autocreated world. Ignored when loading an existing world.
  • seed= – A numeric or alphanumeric string that seeds world generation. Using the same seed and size produces the same world layout. Leave blank for a random seed.
  • difficulty=0 – 0 = Classic (softcore), 1 = Expert, 2 = Master, 3 = Journey. This affects enemy stats, loot, and death penalties. Journey mode also enables the power menu for all players.

Gameplay and Server Behavior Settings

Beyond ports and world files, the config controls how the server behaves during play:

  • motd=Welcome to my server! – The message shown to players when they join. Supports color codes with ^ (e.g., ^red).
  • password= – A password players must enter to join. Leave empty for no password.
  • secure=1 – Enables anti-cheat checks for unusual player data. Recommended for public servers.
  • language=en-US – The server's language for system messages. Common values: en-US, de-DE, fr-FR, es-ES, pt-BR, zh-Hans.
  • upnp=1 – Attempts to automatically forward the port using Universal Plug and Play. Works only if your router supports UPnP and it is enabled. Set to 0 to disable.
  • npcstream=60 – The maximum number of NPCs that can be active at once. Lower values reduce CPU load but may cause NPCs to despawn.
  • priority=1 – Process priority: 0 = Realtime, 1 = High, 2 = Above Normal, 3 = Normal, 4 = Below Normal, 5 = Idle. Use 1 or 2 for dedicated servers.

Common Configuration Mistakes and Fixes

Players often hit the same issues when editing config.txt:

  • Wrong path separators on Linux: Use forward slashes (/) in paths. Backslashes are Windows-only.
  • Spaces around the equals sign: port = 7777 is invalid. The parser expects port=7777 with no spaces.
  • Port already in use: If the server fails to start with “Address already in use,” change the port or kill the process holding it (check with netstat -an on Windows or ss -tulpn on Linux).
  • Firewall blocking: Even with port forwarding, Windows Firewall or a Linux iptables rule can block incoming connections. Add an allow rule for the port on both TCP and UDP.
  • Autocreate not working: The autocreate setting only works if world= is empty or points to a nonexistent file. If you have a world path set, the server will try to load it and fail silently if it is corrupt.

How to Choose the Right Settings for Your Server

For a small group of friends (2–6 players), the defaults work well: port 7777, maxplayers 8, no password, and a small or medium world. For a public server, consider:

  • Set a password to prevent random joins.
  • Enable secure=1 to reduce cheating.
  • Use Medium or Large world to give players room to build without constant overworld crowding.
  • Set difficulty=1 (Expert) if your group wants a challenge; Master (2) is brutal for new players.
  • Lower maxplayers to 4 or 6 if your hardware is modest – each player increases CPU load due to NPC AI and network updates.

If you plan to run the server 24/7, set priority=1 and consider using a Linux server with screen or tmux to keep it running after you log out.

Frequently Asked Questions

How do I change the port after the server is already running?
You cannot change it live. Edit port= in config.txt, save the file, and restart the server. Players must then connect to the new port.

Why can my friends connect via LAN but not over the internet?
This almost always means the port is not forwarded on your router, or your firewall is blocking the port. Check that you forwarded both TCP and UDP to the server's local IP, and that the server machine has a static IP (or you use a DHCP reservation).

Can I use the same world file on a different server?
Yes. Copy the .wld file to the new server and set world= to its path. The world's difficulty and size are stored inside the file, not in the config.

What is the difference between autocreate and worldname?
autocreate tells the server to generate a new world if none exists. worldname is just the display name for that new world. If you load an existing world, worldname is ignored.

Does secure=1 slow down the server?
It adds a small overhead because it validates player data packets, but on a modern machine the impact is negligible. It is worth enabling for public servers to prevent obvious cheats like flying or godmode.

What does npcstream actually do?
It caps the number of NPCs that are updated and sent to players each tick. Lower values reduce network traffic and CPU usage, but can cause NPCs to vanish when too many are active. The default of 60 is fine for most servers.