How to Set Up a Minecraft SRV Record (Hide the Port)

If your server runs on a port other than 25565, players have to type something like 203.0.113.10:25570. An SRV record lets them type play.example.com instead, and Minecraft Java Edition finds the port by itself. It takes two DNS records and a few minutes.

What an SRV record does

Since Java Edition 1.3.1, the game looks up a DNS record called _minecraft._tcp in front of the address a player types. For play.example.com it asks for _minecraft._tcp.play.example.com. If that record exists, it holds a target host and a port, and the game connects there. If it does not exist, the game connects to play.example.com on port 25565, so a server on the default port does not need one.

An SRV record changes what players type, not what is reachable. It does not hide your IP address: anyone can look up the target host. It only hides the port.

What you need first

Step 1: the A record

Skip this if your host gave you a hostname. Otherwise create an A record (AAAA for IPv6) with the name mc and your server's IP as the value, so mc.example.com points to the machine. Do not put the port in it: A records hold only an address.

On Cloudflare, set this record to DNS only (grey cloud). The orange-cloud proxy is built for web traffic, and Cloudflare recommends DNS only for records that serve non-HTTP services. Minecraft is not web traffic.

Step 2: the SRV record

Create a new record of type SRV. Most DNS panels split it into fields:

The finished record is named _minecraft._tcp.play.example.com. If your panel has only one Name field, type _minecraft._tcp.play there. Some panels add the domain for you, so check that it does not end up as _minecraft._tcp.play.example.com.example.com.

Step 3: test it

Enter play.example.com in the SRV record lookup. It shows the target and port Minecraft will use, and the address that target resolves to. Then check the server itself with the status checker.

From a terminal you can run nslookup -q=srv _minecraft._tcp.play.example.com on Windows or dig _minecraft._tcp.play.example.com srv on macOS and Linux. New records usually appear within minutes, but the Minecraft Wiki notes that DNS changes can take up to a day.

Mistakes that break it

Bedrock Edition

The SRV setup above is for Java Edition. The Bedrock client has its own port field, and Mojang does not document SRV lookups for it, so give Bedrock players the address and the port (19132 by default) separately. The Bedrock status checker confirms the server answers on that port.

Frequently asked questions

Do I need an SRV record on port 25565?

No. Without an SRV record, Java Edition connects to the address on 25565 anyway.

Does an SRV record hide my server IP?

No. The target host is public and anyone can look up its address. An SRV record only removes the port from what players type.

What do priority and weight do?

With several SRV records, clients try the lowest priority first, and among records with the same priority a higher weight is chosen more often. With one server, use priority 0 and any weight.

Can I use SRV for several servers on one domain?

Yes. Give each server its own name, such as _minecraft._tcp.survival and _minecraft._tcp.creative, each pointing to its own port.

Sources

Related