Skip to content

Connecting a domain to a FiveM server

Set up A and SRV records at any DNS provider so players join your FiveM server by domain, without an IP address or port.

With your own domain, players join the server with connect play.myserver.com instead of an IP address with a port. You connect the domain where you manage its DNS, so these steps work the same at any registrar and in Cloudflare.

The client panel is available in Polish only, so this article gives its labels in Polish with a translation the first time they appear.

Before you start

  • A domain bought from any registrar.
  • Access to the domain's DNS management. It's usually the registrar's panel, or the Cloudflare dashboard if the domain uses Cloudflare name servers.
  • The server's IP address and port from the Sieć (Network) tab. Use the port marked Domyślny port (Default port), not the txAdmin port.
  • Endpoints in server.cfg set to that port. Setting FiveM server endpoints shows how.

Which records you need

Players reach the server through two DNS records:

  • The A record turns the name play.myserver.com into the server's IP address.
  • The SRV record named _cfx._udp tells FiveM the port. Without it, FiveM connects to the default port 30120, and a Hostero server usually has a different one, so players would have to add the port to the address.

Records for your server

Enter your domain and the address from the panel. The tool shows the values to copy into your DNS provider's form.

The domain you bought from a registrar, without http:// or www.

Leave it empty for players to join on the bare domain.

From the client panel. You can paste the address with its port.

The server's port from the client panel.

Adding the records

  1. Open the domain's DNS zone

    Log in to your DNS provider and open the domain's settings. The section with records is usually called DNS Zone, DNS Records or DNS Management. If the zone already has an A or CNAME record with the same name, change or delete it.

  2. Add the A record

    Choose the A type. In the name field, enter the subdomain, such as play, and in the value field, the server's IP address without the port. Leave the TTL at its default. If the provider shows a proxy switch next to the record, such as the orange cloud in Cloudflare, turn it off so the record is set to DNS only.

  3. Add the SRV record

    Choose the SRV type and copy the values from the tool above. In the name field, enter _cfx._udp.play, and in the target field, the name from the A record, such as play.myserver.com, not the IP address. If the form has separate Service and Protocol fields, enter _cfx and UDP in them, and just play in the name field.

  4. Save the changes

    New records usually start working within a few minutes. Sometimes it takes up to a few hours, because DNS servers remember old answers for as long as the TTL says.

SRV record forms name their fields differently at each provider, but they ask for the same data:

FieldValue
Name, Host_cfx._udp.play or _cfx._udp.play.myserver.com
Priority0
Weight5
Portthe server's port from the panel
Target, Valueplay.myserver.com

Some providers add the domain to the name themselves. If after saving you see the name _cfx._udp.play.myserver.com.myserver.com, enter only _cfx._udp.play in the name field.

Domain without a subdomain

Players can also join on the bare domain, such as myserver.com. Don't change the domain's A record (@) for this: it leads to your website and email, so if you set it to the game server's address, the website stops working.

Instead, add an A record for a subdomain, such as play, as in the steps above, and an SRV record named _cfx._udp (or @ in the name field if the form has separate service and protocol fields) with the target play.myserver.com. FiveM uses the SRV record to reach the server, and the website keeps working.

Only set the @ A record if there's no website on the domain and you don't plan to add one.

Checking

Start FiveM, open the console with F8 and enter:

connect play.myserver.com

If FiveM starts connecting to the server, the records work. You can also check the records with nslookup in a terminal or the Windows command prompt:

nslookup play.myserver.com
nslookup -type=SRV _cfx._udp.play.myserver.com

The first command should show the server's IP address, and the second the port and target from the SRV record.

Common problems

connect works with the IP address and port, but not with the domain

First, check with nslookup that the A record shows the server's address and that the name doesn't have the domain twice, such as play.myserver.com.myserver.com. If the A record is right, FiveM doesn't see the SRV record: check that the name starts with _cfx._udp, that the port is the Domyślny port from the panel, not the txAdmin port, and that the target is a domain name, not an IP address.

The connection fails with records set up in Cloudflare

The A record has the proxy on (orange cloud). The Cloudflare proxy only passes website traffic, so FiveM connects to a Cloudflare server instead of yours. Click the cloud next to the A record to change it to DNS only.

The server can't be reached with either the domain or the IP address

The problem isn't in DNS, but in the server. Check that the server is running and that the endpoints in server.cfg use the port from the panel, as Setting FiveM server endpoints shows.