Option 1: a free subdomain from your host
Some hosts can attach a subdomain to your server without you buying anything. The StormNodes panel has a Subdomains page for exactly this: pick a name and the panel creates the records, so players can connect without typing a port.
If you want your own brand, buy a domain from any registrar and follow the steps below.
Option 2: your own domain with an A record
In your domain's DNS settings, add an A record. The name is the subdomain you want, such as play, and the value is the server's IP address. If the server uses port 25565, you are done: players can join with play.yourdomain.com.
If you use Cloudflare, set that record to DNS only, the grey cloud. Cloudflare's proxy only handles web traffic and will stop Minecraft connections.
Hiding a non-standard port with an SRV record
When the server runs on a port other than 25565, add an SRV record so the client finds the port automatically. Java Edition looks up the service _minecraft over the protocol _tcp.
- Service: _minecraft, protocol: _tcp
- Name: play (or @ for the bare domain)
- Priority 0, weight 5
- Port: your server port, for example 25570
- Target: a hostname with an A record pointing at the server, never a raw IP
Testing and common mistakes
DNS changes can take from a few minutes to a few hours to spread. Test with Direct Connection in the game, or with an online DNS lookup for the SRV record.
The usual mistakes are pointing the SRV target at an IP address instead of a hostname, leaving the Cloudflare proxy on, and typing the full domain into the name field so it ends up as play.yourdomain.com.yourdomain.com.
A note on Bedrock
Bedrock Edition does not read SRV records. Bedrock and Geyser players can use the domain from the A record, but they still need to enter the port in the separate port field.