The port is set by server-port in server.properties and defaults to 25565, TCP. On the default port players just type the IP or domain; on any other port they add it after a colon: play.example.com:25570. Which address to hand out depends on where the player connects from.
Which address to give players
| Connecting from | Address | What you need to set up |
|---|---|---|
| The same computer | localhost | Nothing. |
| The same home network | the internal IP, e.g. 192.168.1.20 | Nothing except the firewall on the server's computer. |
| The internet, server at home | your public IP or a domain | A port forward on the router, plus the firewall. |
| The internet, server on a VPS or game host | the server's IP or a domain | The firewall. On a game host the panel shows the address and port. |
On Windows ipconfig shows the internal IP (the “IPv4 Address” line); on Linux it's ip addr (the inet line of your network interface). Your public IP is in the router's settings or on any “what is my IP” site. If you're still deciding where to run the server, compare the options in game hosting or a VPS.
Port forwarding on a home router
The router is the only device with a public IP; the computers behind it are visible only inside your network. A port forward tells the router: whatever arrives from outside on port 25565, send it to this computer. Router menus differ, but the steps are the same:
- 1
Pin the server's internal IP
The router hands out addresses over DHCP and may give the computer a different one later — then the forward stops working. Reserve the address in the router (DHCP reservation) or set a static IP on the computer.
- 2
Open the router's settings
The router's address is the “Default Gateway” in
ipconfigoutput, often192.168.0.1or192.168.1.1. The login is usually printed on a sticker underneath. - 3
Find port forwarding
It goes by different names: Port Forwarding, Virtual Server, NAT, Applications.
- 4
Create the rule
Internal IP: the server's address. External and internal port:
25565. Protocol: TCP. Name it anything, e.g. minecraft. - 5
Open the port in the computer's firewall
On Windows, the first server start brings up a firewall prompt for “OpenJDK Platform binary” — allow it. On Linux, add a ufw rule (below).
- 6
Test from outside
With the server running, test the port from another network — how is described below.
Firewall on Linux: ufw
On an Ubuntu or Debian VPS the firewall is usually ufw. Open the game port — and allow SSH before enabling the firewall, or you'll lock yourself out:
sudo ufw allow 22/tcp # SSH (or your SSH port)
sudo ufw allow 25565/tcp # Minecraft
sudo ufw enable
sudo ufw status verboseThe game only needs TCP. UDP on the same number is used only by the query protocol if you turned it on (enable-query) — and you shouldn't without a reason. Cloud providers often have their own firewall in the control panel (security groups): the port must be open there as well.
How to check the port is open
- The server is listening. On the machine itself:
ss -tlnp | grep 25565— you should see a java process. Nothing there means the server isn't running or listens on another port. - The port is reachable from outside. From another network (a phone hotspot works):
nc -vz <public-IP> 25565on Linux and macOS, orTest-NetConnection <public-IP> -Port 25565in PowerShell on Windows. - It answers as a Minecraft server. Add the address to the game's server list or check it with an online Minecraft server status tool.
Don't trust a test of your own public IP from inside your own network: many routers can't loop such a connection back (NAT loopback), so the test fails even when everything works from outside.
A domain without a port: the SRV record
A domain is easier to remember than an IP, and moving to another machine is just a DNS change. Start with an A record pointing to the server's IP. On the default port that's all: players type play.example.com.
On a custom port, add an SRV record — since Java Edition 1.3.1 the client reads the port from it. The game looks the record up strictly as _minecraft._tcp.<your domain>, and the value holds priority, weight, port and target — a hostname with an A record, not an IP:
play.example.com. A 203.0.113.10
_minecraft._tcp.play.example.com. SRV 0 5 25570 play.example.com.Check it with dig _minecraft._tcp.play.example.com srv (Linux, macOS) or nslookup -q=srv _minecraft._tcp.play.example.com (Windows). DNS changes take time to spread — sometimes up to a day. If your domain is on Cloudflare, the server's record must be “DNS only” (grey cloud): Cloudflare's proxy only carries HTTP and HTTPS.
Which ports to keep closed
Scanners constantly sweep the internet for Minecraft servers on 25565 and for open service ports. Only the game port should face the outside:
| Port | What it is | Expose it? |
|---|---|---|
25565 TCP (server-port) | The game port | Yes. On a network of servers — only the proxy's port. |
25575 TCP (rcon.port) | RCON, the remote console | No. The connection isn't encrypted and the password can be intercepted. Connect from the machine itself or over SSH. |
25565 UDP (query.port) | The query protocol | Only if you need it. On Paper it sends your plugin list by default. |
| Ports of game servers behind a proxy | Paper behind Velocity with online-mode=false | No. Anyone who reaches such a server directly can join under any name, an admin's included. |
management-server-port | The server management protocol (since 1.21.9, off by default) | No. By default it listens on localhost only — keep it that way. |
On a network of a proxy and several Paper servers, only the Velocity port is public (it defaults to 25565 too), and the game servers listen on 127.0.0.1 or accept only the proxy's IP: sudo ufw allow proto tcp from <proxy IP> to any port 25566. Velocity's documentation states plainly that modern forwarding is not a replacement for a firewall. How to build such a network: Velocity setup.
Your anticheat doesn't need any ports opened. DGuard goes on each game server with its own key and reaches the DGuard site itself over HTTPS — for the license, updates and the cloud check of aim and TriggerBot. So the only firewall requirement is not blocking outbound HTTPS. Install steps are in the guide.
A non-default port and enable-status=false attract fewer scanners, but they won't stop a targeted attack. Bots and DDoS have their own article: bots and DDoS.
FAQ
What port does a Minecraft server use?
25565 over TCP by default. You can change it with server-port in server.properties; players then add the port after a colon, or you set up an SRV record.
Do I need to open UDP for a Minecraft Java server?
No, the game runs over TCP. UDP is only used by the query protocol (enable-query=true), which you shouldn't enable without a reason.
Why can I join my server but my friends can't?
You're most likely connecting through localhost or the internal IP, while friends need the public one. Check the port forward on the router, the computer's firewall, and whether your ISP has you behind CGNAT.
How do I make a server address without a port?
Either keep the default port 25565 and point a domain's A record at the server, or, for a custom port, add an SRV record _minecraft._tcp.<domain> with that port.
Is it safe to open port 25565?
An open game port is normal — every public server has one. What's dangerous is exposing RCON, query without a reason or the ports of servers behind a proxy, and running online-mode=false without an auth plugin.
Sources
- Minecraft Wiki: Java Edition protocol (TCP)
- Minecraft Wiki: server.properties
- Minecraft Wiki: setting up a Java Edition server
- Ubuntu Server: firewalls (ufw)
- Velocity: securing your servers
- Velocity: configuration (bind)
- Paper: bukkit.yml (query-plugins)
- Cloudflare: proxy status of DNS records
- RFC 6598: shared address space (100.64.0.0/10)
- DGuard, the best anticheat for a modern Minecraft server: checks compared with GrimAC, Vulcan, Polar, Intave and Matrix
- DGuard: installation, requirements and troubleshooting
- DGuard: supported Paper and Leaf versions