Port forwarding for a Valheim server
Valheim uses two UDP ports in a row: the game port, and the one just above it for Steam query traffic. Point both at the same machine.
Your setup
Choose the firmware family rather than your exact model — every router in a family shares the same menus.
Out of the box it is 2456. If you changed that, use whatever you set in -port launch argument.
The local address of the computer that runs the server. Find it with ipconfig on Windows or ip addr on Linux; it will begin with 192.168, 10. or 172.
Open these
Your firmware takes ranges, so each line here is one rule.
- 2456-2457 UDP
2456UDPGame trafficThe port you actually connect to.2457UDPSteam queryHow Valheim advertises itself and how the in-game browser finds you. Forward it, or your friends must join by IP every time.
Old versions only
Recent versions never listen on these. They appear here only because outdated tutorials keep recommending them.
2458UDPLegacy Steam portRequired by builds from 2021 and earlier. Harmless to include, unnecessary on current versions.
Do not open these
Good news: this game has no remote-admin port that could be exposed by mistake. Forward the ports on the left and stop there.
Step by step: your router
- 1
Give the server a fixed local IP
A forwarding rule targets a single local address. If the server comes back from a reboot with a new one, the rule quietly points at an empty address — which is how forwards seem to "break by themselves".
On this router:look for DHCP Reservation, Address Reservation, Static Lease or Manually Assigned IP
- 2
Open the router admin page
From a device on the same network, open one of these in a browser:
- 192.168.0.1
- 192.168.1.1
- 192.168.2.1
- 10.0.0.1
Almost always printed on a sticker on the router itself.
- 3
Find the port forwarding page
Port Forwarding, Virtual Server, NAT, Applications & Gaming, or Port Mapping
Vendors use at least six names for the same feature. Whatever it is called, the page you want is the one asking for a port, a protocol and a device on your network. If the external and internal port fields both exist, set them to the same number.
- 4
Create one rule per line
a description field, if there is one External / WAN / Public / Service port Internal / LAN / Private port Protocol Internal IP / Device / Server IP Valheim 2456-2457 2456-2457 UDP your server’s local IP Use the same number for the external and internal port. You can make the external one different, but then every player has to connect on that new number, so keep them identical unless you have a specific reason not to.
- 5
Let the server through its own firewall
The router is now sending traffic to the right computer, but that computer can still turn it away. Windows Defender Firewall is the usual offender: it blocks a newly installed dedicated server by default, and from outside that is indistinguishable from a broken forward.
Take it with you
Valheim — port forwarding rules ------------------------------- 2456-2457 UDP -> <server local IP>
Check whether it worked
Always test from outside your network. A connection from another device in the house proves nothing: that traffic stays on your LAN and never passes through the rule you just created.
Advertisement
The usual mistake
Leave out the query port and the server works while looking broken. Friends who type in your address still get in, but it never shows in the in-game community browser or in anyone's favourites, which looks exactly like a failed setup. Some older guides list a third port; builds from 2021 needed it, and today it does nothing, harmful or otherwise.
Advertisement
Skipping port forwarding
Valheim's crossplay backend can relay a game hosted from inside the client, with no forwarding, but that world only exists while the host is playing. A dedicated server is what lets your friends drop in when you are not around.
Where the port number comes from
Valheim has no config file for networking. The game port is the -port argument on the server's launch line, which on Windows lives in start_headless_server.bat. Whatever number you put there, the server also listens on the next one up for queries, which is why the generator above only asks for one number and gives you two rules. Keep the port at 65534 or below so the query port still fits.
Two servers on one machine
Each Valheim server takes its port and the one above it, so a second server cannot start at 2457: that port already belongs to the first server's queries. Start it at 2458, which gives it 2458 and 2459, and forward that pair separately. The same rule applies to a third server and beyond: always step by two.
The firewall on the server itself
Forwarding gets traffic to the machine; the machine still has to accept it. On Windows, the first launch of valheim_server.exe usually raises a firewall prompt, and answering it for private networks only is enough to block everyone outside. On a Linux server using ufw, the rule for a default install is: ufw allow 2456:2457/udp