How to connect a domain name to a Minecraft server?

To use a custom domain name, resolve the game address to the server's public IP. You can keep the website address and game address in different subdomains.

Step by step

  1. Get the IP address and port available to players from the server provider. Using the address of the administration panel or the local IP of the machine.

  2. Add an A record named play to the DNS zone and write the IPv4 address as a value. If IPv6 is actually being listened to, add the AAAA record, don't publish a non-working IPv6 address.

  3. If you're using Cloudflare, set the game subdomain to DNS only in your regular DNS record. If Java uses a private port, share the port or create a separate SRV record.

  4. Query the domain name from a different network and compare the result with the numerical address. If the numerical address works but the domain name does not, examine the DNS side.

Keep in mind

DNS record handles name resolution. Port forwarding and server listening are also required.

Source and tools