To port forward, give the device a fixed local IP address, then log in to your router's admin page (the "Default Gateway" address from ipconfig), open the Port Forwarding section, and create a rule that sends the external port (for example TCP 25565) to that device's local IP and port. Then allow the port in the device's firewall and test it from outside your network.
If it still doesn't work after that, the most common cause is that your internet provider uses carrier-grade NAT, which no router setting can fix. How to check that is covered below.
What port forwarding does
Your home devices use private addresses such as 192.168.1.50, and they share one public address through the router's NAT. Outbound traffic works automatically: the router remembers who asked for what and routes the replies back. Inbound connections are the problem. When someone on the internet connects to your public address on port 25565, the router has no idea which of your devices should receive it, so it drops the connection.
A port forward is the instruction that fills that gap: "traffic arriving on port 25565 goes to 192.168.1.50". RFC 3022, which describes traditional NAT, notes that sessions are normally outbound only and that inbound access is allowed "on an exceptional basis using static address maps", by statically mapping a local node to each service port. That static map is a port forward. Public vs private IP addresses explains the address side in more detail.
Step 1: find the device's local IP and the router address
On Windows, run ipconfig. Example output:
Wireless LAN adapter Wi-Fi:
IPv4 Address. . . . . . . . . . . : 192.168.1.50
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
The IPv4 Address is the device you forward to. The Default Gateway is your router's admin address. On macOS, ipconfig getifaddr en0 prints the Wi-Fi address and route -n get default shows the gateway; on Linux, ip addr and ip route show the same.
Step 2: give the device a fixed local IP
Routers hand out local addresses through DHCP, and the address can change after a reboot. If it does, your forward points at the wrong device or at nothing. Fix the address in one of two ways:
- DHCP reservation (preferred): in the router's LAN or DHCP settings, reserve the current IP for the device's MAC address. The router always gives that device the same address.
- Static IP on the device: set the address manually, choosing one outside the router's DHCP pool so nothing else gets it.
Step 3: add the port forwarding rule in the router
Open the gateway address in a browser (for example http://192.168.1.1) and log in. The admin password is often printed on a label on the router. The section's name varies by manufacturer: Port Forwarding, Virtual Server, NAT or a similar heading, sometimes under Advanced. A rule has these fields:
| Field | What to enter | Example |
|---|---|---|
| Name / Service | Any label | Minecraft |
| Protocol | TCP, UDP or both, as the program's documentation says | TCP |
| External (WAN) port | The port people connect to | 25565 |
| Internal (LAN) IP | The device from step 1 | 192.168.1.50 |
| Internal port | The port the program listens on (usually the same) | 25565 |
Getting the protocol right matters: a forward for TCP does nothing for a program that uses UDP. TCP vs UDP explains the difference. Save the rule; some routers need a reboot before it takes effect.
Step 4: make sure the program is listening and the firewall allows it
A forward only delivers the connection to the device. Two things on the device still have to cooperate:
- The program must be running and listening. Check with
netstat -ano | findstr :25565on Windows orss -ltnpon Linux. If nothing shows aLISTENINGstate on that port, the server isn't running or uses a different port. - The firewall must allow inbound traffic. Windows usually prompts the first time a program listens. To add a rule yourself, run this in an administrator PowerShell:
New-NetFirewallRule -DisplayName "Minecraft TCP 25565" -Direction Inbound -Protocol TCP -LocalPort 25565 -Action Allow
On Ubuntu with ufw, the equivalent is sudo ufw allow 25565/tcp.
Step 5: test it from outside
Testing from inside your own network often gives a misleading answer, because many routers don't loop a connection to their own public address back inside (a feature called NAT loopback or hairpinning). Test from a phone on mobile data with Wi-Fi off, or ask someone elsewhere to connect. From another Windows machine outside your network:
Test-NetConnection -ComputerName 203.0.113.25 -Port 25565
TcpTestSucceeded : True means the whole path works. 203.0.113.25 is a documentation placeholder; use your own public address. This command only tests TCP; for a UDP-only service, test with the program itself.
Why port forwarding isn't working: CGNAT
Some providers put customers behind carrier-grade NAT (CGNAT): your router itself gets a private address, and the provider shares one public address among many customers. You can't forward through the provider's NAT, so inbound connections never reach your router.
To check, open your router's status page and find its WAN (internet) IP address, then compare it with your public IP as seen by any "what is my IP" website:
- They match: you have a public address and port forwarding can work.
- The WAN address starts with 100.64 to 100.127: that is the shared address space
100.64.0.0/10reserved for carrier-grade NAT by RFC 6598. You are behind CGNAT. - The WAN address is 10.x, 172.16-31.x or 192.168.x: there is another router or NAT in front of yours (often the provider's modem-router, or CGNAT using private space).
Fixes for CGNAT: ask your provider for a public IPv4 address, use IPv6 if both ends support it, or use a tunnel or VPN service that gives you a reachable endpoint.
Double NAT: two routers in a row
If your provider's modem is also a router and you plugged your own router in behind it, you have two NATs. A forward on your router alone isn't enough. Either put the provider's box into bridge mode so only your router does NAT, or add a matching forward on the provider's box pointing at your router's WAN address.
Automatic port forwarding: UPnP and PCP
Many games and consoles open ports themselves using UPnP or the Port Control Protocol (PCP, RFC 6887), which lets a host ask the NAT or firewall to create a mapping so it can receive incoming connections. If your router has UPnP enabled, you may not need a manual rule at all. The same mechanism lets any program on your network open ports without asking, which is why some people disable it.
If it still fails
Work from the inside out. Confirm the program is listening on the expected port. From another device on the same network, connect to the local address (for example Test-NetConnection 192.168.1.50 -Port 25565); if that fails, the problem is the program or the device firewall, not the router. If the local test works but the outside test fails, re-check the rule's IP and protocol, then check for CGNAT or double NAT. Some providers also block certain inbound ports on residential connections; forwarding a different, unusual external port to the same internal port is a quick way to test for that.
Frequently asked questions
- Is port forwarding safe?
- It exposes one service on one device to the whole internet, so it is as safe as that service. A patched game server or a VPN endpoint with strong authentication is a reasonable thing to forward. Remote desktop, file shares, camera admin pages and databases are risky to expose directly; a VPN into your home network is the safer way to reach them.
- What is the difference between port forwarding and port triggering?
- Port forwarding is a permanent rule: traffic to a port always goes to one device. Port triggering opens an inbound port only after a device on your network sends outbound traffic on a chosen trigger port, and closes it again after a period of inactivity. Not every router offers triggering.
- Do I need port forwarding with IPv6?
- Usually not in the same form, because IPv6 devices get globally routable addresses and there is no address translation to work around. You still need to allow the inbound connection in your router's IPv6 firewall, which is often a separate setting, and the person connecting must also have IPv6.
- Should I use UPnP instead of manual port forwarding?
- UPnP lets programs on your network open ports on the router automatically, which is convenient for games and consoles. The trade-off is that any program on the network, including malware, can open ports without asking you. Many people turn it off and add the few forwards they need by hand.