Open ports and test port forwarding
Open a port in the router and the firewall, test it from outside, and the most common reasons why it fails, such as DS-Lite.
Want to reach a game server, a camera or a small web server at home from the outside? Then the port has to get through two places: the router and the firewall of the device. Here you will see how to set up both, how to test it from outside and what to do if it still does not work.
What a port is
An IP address gets data to the right device, the port gets it to the right program on that device. A web server usually listens on port 443, SSH on 22, a Minecraft server on 25565. Ports exist for TCP and for UDP, and they are separate: TCP port 25565 being open does not mean UDP port 25565 is open.
1. Is the program running at all?
First check on the device itself whether the program listens on the port. On Linux:
sudo ss -ltnp # TCP
sudo ss -lunp # UDP
On Windows in PowerShell:
Get-NetTCPConnection -State Listen | Sort-Object LocalPort
If it shows 127.0.0.1:25565, the program only listens for the computer itself. It has to be switched to 0.0.0.0 (all addresses), otherwise no forwarding will help.
2. Firewall of the device
- Windows: the Windows firewall usually asks the first time the program starts. If you declined, add an inbound rule for the port under Windows Defender Firewall with Advanced Security.
- Linux with UFW:
sudo ufw allow 25565/tcp
3. Forwarding in the router (IPv4)
At home all devices share one public IPv4 address. The router therefore needs to know which device should receive incoming connections on a port.
- Give the device a fixed address in your home network, for example
192.168.178.20. Routers usually offer this under Home network or DHCP ("always assign the same IP address"). - Create a port forwarding rule in the router. Depending on the vendor it is called port sharing, port forwarding or virtual server.
- Choose the device, the protocol (TCP, UDP or both) and the port.
4. IPv6: opening instead of forwarding
With IPv6 every device has its own public address. Nothing is forwarded, but the router firewall has to open the port for exactly this device. In many routers you tick an extra box for IPv6 in the same port sharing rule.
5. Test from outside
With the port check you can see whether a TCP port is reachable from outside. It tests the address you open the page from. If you come in over IPv6, the tool tests your IPv6 address. What is my IP shows the addresses you currently have.
Important: do not test from your own Wi-Fi against your own public address with a program like nc. Many routers do not loop such connections back into the home network, and a working port then looks closed.
UDP ports cannot be tested reliably this way: without a matching answer from the program, an open UDP port looks the same as a blocked one. For games use the game server status instead, which queries the server the way the game does.
It does not work: the most common reasons
DS-Lite or CGNAT. Many cable and fibre connections no longer have their own public IPv4 address. You share it with other customers of your provider, and IPv4 forwarding is not possible. You can tell when the router shows an IPv4 address from 100.64.0.0/10, or a different one than "What is my IP". Then only IPv6, a real IPv4 address from your provider (often on request) or a server of your own on the internet will help.
Wrong port. Some games do not answer queries on the game port but on a separate query port.
The program only listens locally. See step 1.
Two routers in a row. If your router sits behind another device from your provider, both need a forwarding rule, or you switch the front device to bridge mode.
Without router trouble
A server of your own in a data centre has a fixed public IPv4 address and its own IPv6 network, without a router and without DS-Lite. You open ports there with a few clicks in the firewall in the customer area, see Secure your server: combine the panel firewall and UFW.
For the community
Know your stuff? Write a guide.
Share what you know: we review every submitted guide, publish it under your name and say thank you with credit for your services.