Valheim Server Disconnected Error: Ports, Crossplay & Firewall Fixes
In this article
If you are seeing a "disconnected" error when joining a Valheim dedicated server, especially with crossplay enabled, the cause is almost always a port forwarding or firewall misconfiguration. This article explains exactly which ports Valheim uses, how to open them on your router and firewall, and how to fix crossplay connection issues step by step.
Background: Why Valheim Servers Disconnect
Valheim's dedicated server software listens for incoming connections on specific network ports. When you start a server, it binds to a port (default 2456) and expects clients to connect to that port. The "disconnected" error appears when the client cannot establish or maintain a stable connection to that port. This can happen for several reasons:
- The port is not forwarded on the host's router (if the server is behind NAT).
- A firewall on the host machine (Windows Defender, third-party antivirus) is blocking inbound traffic.
- The server's IP address or port number is entered incorrectly in the client.
- Crossplay (joining from Xbox or via the in-game server browser) requires additional UDP ports that are not open.
How Valheim Ports Work
Valheim uses a range of three consecutive UDP ports for each server instance. The base port is set in the server's start parameters (default 2456). The server actually listens on the base port, base+1, and base+2. For a default server, these are:
- 2456 – used for the game traffic (primary connection)
- 2457 – used for the game traffic (secondary)
- 2458 – used for Steam query / server listing
All three must be reachable by clients. If you only forward 2456, the client may connect briefly but then drop, causing the "disconnected" error. When you set a custom port (e.g., 7777), the server will use 7777, 7778, and 7779.
Crossplay and Port Requirements
Crossplay in Valheim allows players on Steam and Xbox (including Game Pass) to join the same server. This feature uses the same UDP ports as normal, but it also relies on the server being visible to the crossplay matchmaking service. If you are hosting a dedicated server with crossplay enabled (using the -crossplay launch argument), you must ensure that the three UDP ports are open both on the router and on the host's firewall. Additionally, the server needs to send outbound UDP traffic to the matchmaking service, which is usually allowed by default, but some strict firewalls may block it.
Step-by-Step Fixes for the Disconnected Error
Here are the exact steps to resolve the issue, from most common to least common:
- Open the ports on your router. Log into your router's admin page (typically 192.168.1.1 or 192.168.0.1), find the "Port Forwarding" or "Virtual Server" section, and create a rule that forwards UDP ports 2456-2458 to the local IP address of the machine running the server. If you are using a custom port, forward that port and the next two numbers.
- Allow Valheim through Windows Firewall. Open Windows Defender Firewall, click "Advanced settings", then "Inbound Rules" -> "New Rule". Choose "Port", select UDP, enter 2456-2458, allow the connection, and apply it to all profiles. Do the same for the game executable if prompted.
- Set a static IP for the server machine. If your server PC's IP address changes, the port forward will break. Reserve an IP address in your router's DHCP settings, or set a static IP on the server machine itself.
- Verify the server is actually running. Check that the server console shows "Game server connected" and that the process is listening on the correct ports. On Windows, use
netstat -an | findstr 2456to confirm. - Test the port from outside. Use an online port checker tool (like yougetsignal.com) to see if the ports are reachable from the internet. If they are not, your router or ISP may be blocking them.
- If crossplay still fails, try disabling crossplay. Run the server without the
-crossplayargument and connect via the Steam server browser. If that works, the issue is specifically with crossplay matchmaking, which may require opening additional outbound ports or updating the game.
Common Mistakes and Misconceptions
Many players assume the error is due to a bad password or mod conflict, but in most cases it is a port issue. One common mistake is forwarding only the base port (2456) instead of the full range. Another is using TCP instead of UDP – Valheim uses UDP exclusively. Also, if you are hosting on a VPS or cloud provider, you must open the ports in the provider's firewall as well as the OS firewall. Finally, if you are using a VPN on the server machine, it can interfere with inbound connections – disable it or configure split tunneling.
Firewall and Router Configuration Details
For Windows Firewall, the rule should be set to allow inbound UDP on ports 2456-2458. If you have multiple network profiles (Private, Public), apply the rule to all. For Linux servers, use ufw allow 2456:2458/udp. On your router, the port forward rule should use the server's local IP (e.g., 192.168.0.10) and the same port range. Do not use port triggering or DMZ as a shortcut – DMZ exposes the entire machine, which is a security risk.
When the Fix Doesn't Work: Advanced Troubleshooting
If you have opened the ports and still get disconnected, try these additional checks:
- Check if your ISP uses Carrier-Grade NAT (CGNAT). If your router's WAN IP is not a public IP (e.g., it starts with 100.64.x.x), port forwarding will not work. You may need to request a public IP or use a VPN tunnel like Hamachi or Tailscale.
- If you are using a modded server, some mods can cause disconnects. Test with a vanilla server first.
- If you are joining via the in-game browser, the server may not be listed if the query port (2458) is closed. Always join via the "Join IP" option and enter the IP and port manually.
- If you are on Xbox and connecting to a PC server, ensure both are updated to the same version of the game.
Frequently Asked Questions
What ports does Valheim use for crossplay?
The same UDP ports as normal: 2456, 2457, and 2458 (or your custom base port plus the next two). Crossplay does not use a separate port range; it just requires those ports to be open and reachable.
Why does my Valheim server show as offline in the browser?
This is usually because the query port (2458) is not forwarded or the server's firewall is blocking it. Make sure all three UDP ports are open, and check that the server is running without errors.
Can I use TCP instead of UDP for Valheim?
No, Valheim uses UDP for all game traffic. Forwarding TCP ports will not help and may cause confusion.
Do I need to open ports for a LAN server?
No, if all players are on the same local network, port forwarding is not needed. Just ensure the host's firewall allows inbound connections on the Valheim ports.
How do I find my server's local IP address?
On Windows, open Command Prompt and type ipconfig. Look for the IPv4 address of your active network adapter (e.g., 192.168.1.100). On Linux, use ip addr or ifconfig.
What if my ISP blocks port forwarding?
Some ISPs use CGNAT, which prevents inbound connections. You can request a public IP address (often for a fee) or use a VPN service that provides port forwarding, such as a dedicated server or a tunnel like Playit.gg.