RE:NODE

Valheim server ports: 2456, 2457 and 2458 explained

By RE:NODE Team
10 min read


A Valheim dedicated server needs two UDP ports: the game port, 2456 by default, and the port above it, 2457, which answers Steam's server queries. Change the game port with -port and both move together - -port 2500 means 2500 and 2501. The 2456-2458 range in older guides and Iron Gate's original instructions is a safe over-allowance, not a third requirement; forwarding it does no harm, but the server does not depend on 2458. Everything is UDP. A TCP rule, however carefully written, does nothing for Valheim. The rest of this post covers what each port is for, how to open them at home and on a Linux or Windows machine, how crossplay changes the picture, and how to fit several servers on one address.

What each port does#

PortProtocolPurposeNeeded for
2456 (the -port value)UDPGame trafficJoining by IP, playing
2457 (-port + 1)UDPSteam queryCommunity list, Steam server browser
2458 (-port + 2)UDPNot used by current buildsNothing - forward it if a guide insists

The game port carries the session itself: positions, zone data, building, chat. When a Steam player types an address into Join Game, it is this port they connect to.

The query port is how a server describes itself to the outside world without anyone joining: its name, the player count, whether it has a password, its version. The community list and Steam's own server browser read it. If only the query port is blocked, the server works perfectly for people who join by IP and never shows in a list - one of the most common Valheim support questions, with its own post: Valheim server not showing in the list.

2458 comes from early builds and from Iron Gate's original setup notes, which told people to forward 2456-2458. Current dedicated servers bind the game port and the one above it. If you are forwarding a range anyway, three ports cost nothing; if you are allocating ports individually, two is enough.

The general idea of game versus query ports, across games, is in game server ports explained, and the query protocol itself in query ports and A2S.

How -port shifts the pair#

The server takes one port argument and derives the query port from it:

bash
$ ./valheim_server.x86_64 -nographics -batchmode \    -name "Longship Crew" -world "Midgard" \    -password "herring-barrel-42" -port 2466

This server uses UDP 2466 for the game and 2467 for queries. There is no separate query-port argument; the relationship is fixed. Three rules follow:

  1. Both ports must be free and reachable. A host or firewall that opens only the number you typed in -port gives you a server that cannot be listed.
  2. Choose game ports at least two apart when several servers share a machine. 2456 and 2457 as two game ports would make the second server's game port the first server's query port, and one of them fails to bind.
  3. Players joining by IP use the game port, not the query port: 203.0.113.10:2466.

The one exception to rule three is Steam's own server browser (View, then Game Servers, then Favourites, outside the game). Adding a server there uses the address Steam queries, which is the query port: 203.0.113.10:2467. Inside Valheim, always the game port.

Every other launch argument, with defaults and the mistakes people make with them, is in the Valheim launch arguments reference.

Crossplay and the relay#

With -crossplay, the picture changes for some players. Crossplay servers are reached through PlayFab's relay using the six-digit join code, so an Xbox or Game Pass player using the code connects to the relay, and the relay talks to the server. That traffic does not need an inbound forward on your router in the same way direct joins do, which is why a crossplay server at home is sometimes joinable by code while nobody can reach it by IP.

Do not rely on that. Steam players joining by IP still connect straight to the game port, the community list still needs the query port, and the relay adds a hop to every packet. Open the ports properly and treat the code as a convenience, not a workaround. Valheim crossplay and Xbox players has the rest of what crossplay changes.

Opening the ports on the machine#

A server on your own Linux or Windows machine needs the operating system's firewall to let the traffic in, before any router is involved.

On Ubuntu or Debian with ufw:

bash
$ sudo ufw allow 2456:2457/udp comment "Valheim"$ sudo ufw status numbered

The /udp is not optional. sudo ufw allow 2456 without it opens both TCP and UDP on one port only, and leaves the query port closed. The ufw firewall guide covers rules, ordering and removing them again.

With plain iptables, if that is what the machine uses:

bash
$ sudo iptables -A INPUT -p udp --dport 2456:2457 -j ACCEPT

That rule does not survive a reboot on its own; save it with whatever your distribution uses (netfilter-persistent save on Debian-based systems with that package installed).

On Windows, the first start of valheim_server.exe usually shows a Windows Defender Firewall prompt. Allow it on private networks at least. If the prompt was dismissed, or you want an explicit rule, run this in an administrator PowerShell:

code
New-NetFirewallRule -DisplayName "Valheim server" -Direction Inbound `    -Protocol UDP -LocalPort 2456-2457 -Action Allow

A rule tied to the program rather than the ports also works, and survives a -port change, but breaks when SteamCMD installs the server into a different folder. Port rules are easier to reason about.

Forwarding at home#

A server on a home connection needs one more step: the router must send incoming UDP on those ports to the PC running the server.

  1. Give the server PC a fixed LAN address. Either a DHCP reservation in the router or a static address on the PC. A forward to 192.168.1.50 stops working the day the PC comes back as 192.168.1.51.
  2. Create the forward. External ports 2456-2457, protocol UDP, internal address the server PC, internal ports 2456-2457. Routers label this "port forwarding", "virtual server" or "NAT rules". If the router offers "TCP/UDP" or "Both", that is fine; "TCP" alone is not.
  3. Find your public address. The router's status page shows its WAN address; if it starts with 100.64 to 100.127, 10., 172.16 to 172.31 or 192.168, your provider is using carrier-grade NAT and no forward on your router can work.
  4. Test from outside. Ask a friend to join by IP, or use a phone on mobile data. Testing from inside your own network proves nothing - see below.

The CGNAT case in step three is common on mobile, fibre and cable connections, and the options it leaves - asking the provider for a public address, a VPN with port forwarding, or hosting elsewhere - are compared in NAT and CGNAT for game hosts. Port forwarding vs hosted servers covers the router features that get in the way: UPnP fighting manual rules, double NAT behind an ISP modem, and addresses that change overnight.

Joining your own server from the same network

People forward the ports, try to join their public address from the PC next to the server, and conclude the forward is broken. It may be fine. Connecting to your own public address from inside the network needs a router feature called NAT loopback or hairpinning, which many home routers lack.

Players on the same network should join by the server's LAN address instead, such as 192.168.1.50:2456. Players outside use the public address. If outside players can get in, the forward works, whatever happens from the inside.

UDP 2456UDP 2457direct, no forwardFriend outsidejoins public IPPlayer on your LANjoins 192.168.x.xCommunity listqueries 2457Home routerforwards UDP 2456-2457Valheim servergame 2456, query 2457
Who connects to which port on a home Valheim server

Several servers on one IP#

Running two or three Valheim servers on one machine or one address is common - a vanilla world and a modded one, or a main world and a test copy. Each needs its own pair of ports, and each should have its own save folder.

bash
# Server A - the main world$ ./valheim_server.x86_64 -nographics -batchmode -name "Midgard Main" \    -world "Midgard" -password "herring-barrel-42" -port 2456 \    -savedir "/srv/valheim/main"# Server B - a modded test world$ ./valheim_server.x86_64 -nographics -batchmode -name "Midgard Test" \    -world "MidgardTest" -password "herring-barrel-42" -port 2466 \    -savedir "/srv/valheim/test"

Spacing game ports by ten (2456, 2466, 2476) is a habit rather than a rule - two apart is the technical minimum - but it leaves room and makes the ports easy to tell apart in firewall rules. Forward or allow each pair: 2456-2457 and 2466-2467 here.

The separate -savedir matters as much as the port. Two servers sharing a save folder share adminlist.txt, bannedlist.txt and permittedlist.txt, and if their world names ever coincide they overwrite each other's saves. Valheim save locations covers the layout. If the servers run as separate system users, each gets its own default save folder anyway, but setting -savedir makes it explicit.

Players tell the servers apart by name in the list and by port when joining by IP. Join codes on crossplay servers are per server, so that path needs no extra thought.

Ports on a hosted server#

On a hosted server you do not choose the address or edit a router. The host allocates ports from its own range, and the job is to make sure the server uses the ones it was given.

Three things to check:

  • The game port in the startup line matches the allocation. On a panel host the -port value is usually filled in from the primary allocation automatically. If you edit the startup command by hand, keep it.
  • The query port is allocated too. Because Valheim derives it as the game port plus one, the host needs to give you that next port, not an arbitrary second one. A query port allocated as some unrelated number does nothing for Valheim.
  • Join by the address and port the panel shows. It may not be 2456. A server at 203.0.113.10:27015 is joined at exactly that.

On RE:NODE each Valheim plan comes with two ports allocated, the game port and its query port, and the Network tab is where allocations are listed, added and removed. A hosted server also sidesteps the home problems in the previous section - there is no CGNAT, no router and no loopback to worry about, only the two UDP ports.

Testing that the ports are open#

UDP is awkward to test. There is no connection to establish, so a "port checker" website that tries to connect usually reports a UDP port as closed or unknown even when it is working. Valheim gives you better tests:

  1. Join by IP from outside the network. If that works, the game port is open. Nothing else proves it as directly.
  2. Look for the server in the list, or add it to Steam's favourites by its query port. If Steam shows the name and player count, the query port answers.
  3. Query it with a tool. Anything that speaks Steam's A2S protocol can ask the query port for the server's info. A reply means the port is reachable and the server is up.
  4. Watch the server log while someone connects. A connection attempt that reaches the server leaves a line. Nothing at all in the log means the packets never arrived - a firewall, forward or wrong address, not the game.

If join by IP fails with nothing in the log, the problem is the network path. If the log shows the attempt and the player is then rejected, the ports are fine and the reason is in the message - version, password, ban or a full server, each covered in Valheim failed to connect errors.

FAQ#

Is Valheim TCP or UDP?

UDP, for both the game port and the query port. A TCP rule for 2456 is the most common reason a carefully forwarded server cannot be reached.

Do I need to forward 2458?

No, not for current builds. Older guides list 2456-2458 and forwarding all three causes no harm, but the server uses the game port and the one above it.

Which port do I type when joining by IP?

The game port - 2456 unless the server was started with a different -port. The query port is only for Steam's own server browser favourites, outside the game.

Can I run Valheim on port 27015 or any other port?

Yes. Any free UDP port works with -port, as long as the next port up is free and open too. Players then join at that port, and the list finds it through the port above.

Why can my friends join but I cannot, on my own network?

Your router probably lacks NAT loopback, so it cannot route your own public address back inside. Join by the server's LAN address instead; outside players use the public one.

Do crossplay servers still need open ports?

For Steam players joining by IP and for the community list, yes. Join-code players go through the relay, but a server that only works by code is half-configured and slower than it needs to be.