How do I set up a Terraria multiplayer server?
I am trying to set up a Terraria server that my friend and I can play on. We are both playing the Steam version. I believe I have it running, but when I send them an invite through Steam, it doesn't work. They say that it just keeps loading but never goes anywhere.
I have tried searching how to set up a multiplayer server on YouTube, but the instructions they give either aren't clear or they don't work.
How do I determine what my IP and port are? Is this my public IP, or is it like a 'world' IP or something? Do we need to download and set up a VPN? Or is there an easier way to get this working without downloading anything?
Even if you know your port and public IP, there are a few things you need to consider if you want to host a server.
Firewall
Your router (the thing that connects your home network to the internet) has a firewall that blocks any incoming traffic that isn't a response to some outgoing traffic. This is to protect your home network from possible attacks from the outside.
However, when you set up a server, you're expecting people from the outside connecting to it. As a result, you must tell your router that connection attempts from the outside should be allowed. There are 3 ways to do this:
-
Port forwarding: You are telling your router that only messages to a specific port or range of ports is allowed to go through the firewall, and should be forwarded to a specific computer (your server). This is the recommended approach as it limits the range of attacks that can be launched against your server.
-
Automatic port forwarding (UPnP): Same as before, but much more convenient as your devices can now open ports on their own. This can leave your home network vulnerable if a malevolent actor somehow gains access to your home network. Examples include but are not limited to: Malware, hacked WiFi, insecure devices that forget to close ports when they're done, etc. Note that the software (the Terraria server software) must support this feature to make use of it.
-
Demilitarized Zone (DMZ): The DMZ is a zone in your home network that is fully open to the outside. By putting your server in the DMZ, you are essentially leaving it outside of your firewall's protection, enabling anyone to access your server using any port. You should only use a DMZ if you know exactly what you're doing, both in terms of networking as well as in terms of security. In some home routers, the DMZ is not isolated from your home network. In that case, if your DMZ gets compromised, it'll compromise the rest of your home network.
How to enable/disable or configure port forwarding, UPnP or DMZ depends on your router.
Remember that your server may also have its own firewall, so even if you've opened a port on your router's firewall, your server may itself be refusing the connection. The solution here is to allow your software (the Terraria server software) to bind to the ports it needs.
Dynamic IP addresses and leasing
Due to the limited amount of IPv4 addresses (and IPv4's enduring popularity), the public IP address you have now may change at any moment. When and how often it changes depends on many factors.
If this happens to you, your friend will need to know your new public IP address to connect again. To avoid this, you can use a so-called dynamic Domain Name System (dynamic DNS, or DDNS). Your server will periodically contact the DDNS server, which will assign a URL (such as example.com) to your current public IP address.
For additional safety, it's recommended to request a certificate from a Certificate Authority (CA) such as Let's Encrypt, so your friend can be sure they're connected to your server, and not to some malicious server pretending to be you.
Port
You should be able to find the port in the console window that your server starts in (I would get the V4).
IP
Just search up "what is my IP."