The hostname is the server's own name, such as server.example.com. cPanel uses it for the WHM address, the SSL certificate on ports 2083 and 2087, and the greeting your mail server gives other servers. A bad hostname causes certificate warnings and mail rejections. This guide shows how to change it the right way and what to check afterwards.
Before you start
- cPanel & WHM installed on a Linux VPS, with root access to WHM.
- Access to the DNS for the domain you will use for the hostname.
- The server IP from your VPS provider's control panel, for example
203.0.113.10.
Choose a good hostname
A hostname for cPanel must:
- be a fully qualified domain name with at least three parts, such as
server.example.com; - be 60 characters or fewer;
- not be the same as any website domain on the server. Use a subdomain, not
example.comitself; - resolve to the server's IP address.
Good choices are short and neutral: server1.example.com, vps.example.com or host.example.com.
Tip: Use a domain you will keep long term. Changing the hostname later means repeating the SSL and mail steps below.
Add the A record first
At the DNS provider for example.com, create an A record:
server.example.com. A 203.0.113.10If the domain's DNS is hosted on this cPanel server, add the record in Home » DNS Functions » Zone Editor instead.
Wait until it resolves:
dig +short server.example.comThe output should be 203.0.113.10. Setting the hostname before DNS is ready makes WHM warn that the name does not resolve.
Change the hostname in WHM
- Log in to WHM at
https://203.0.113.10:2087as root. - Go to Home » Networking Setup » Change Hostname.
- Enter the new FQDN, for example
server.example.com. - Click Change.
WHM updates the system hostname and the cPanel configuration that depends on it. Some services restart, which can take a minute.
You can confirm from SSH:
hostname -fWarning: Do not change the hostname only with hostnamectl. cPanel stores the hostname in its own configuration too, and changing it outside WHM leaves them out of step.
Add the matching PTR record
Mail servers check that your IP's reverse DNS (PTR) matches the hostname your server announces. A mismatch is a common reason for mail being marked as spam. Set the PTR for 203.0.113.10 to server.example.com. If the Dashboard does not offer a reverse DNS setting for your service, open a ticket and ask for it.
Check it:
dig +short -x 203.0.113.10Fix the hostname SSL certificate
The old certificate was issued for the old name, so browsers will warn on port 2087. Run AutoSSL so it requests a certificate for the new hostname:
/usr/local/cpanel/bin/checkallsslcertsThis script checks the service certificates and requests a new hostname certificate if needed. It can take a few minutes. The full process is in secure the WHM hostname with a free SSL certificate.
Check the mail banner
Exim greets other mail servers with the hostname. Test it from the server with nc:
nc localhost 25The first line should begin with 220 server.example.com ESMTP. Type QUIT to close. If it still shows the old name, restart Exim from Home » Restart Services » Mail Server (Exim).
Check it works
hostname -fprints the new FQDN.https://server.example.com:2087loads WHM without a certificate warning.- The SMTP banner shows the new name.
dig -xon the server IP returns the new hostname.
Troubleshooting
- "The hostname does not resolve" warning: the A record is missing or has not propagated. Check with
digand wait. - Certificate still shows the old name: AutoSSL has not run yet or failed validation. Run
checkallsslcertsagain and check the output for DNS errors. - Mail rejected with HELO or rDNS errors: the PTR record does not match the hostname. Update reverse DNS.
- Hostname reverts after a reboot: it was changed outside WHM. Set it again in Change Hostname.
Next steps
- Secure the new name: secure the WHM hostname with free SSL.
- Fix mail client warnings next: manage service SSL certificates in WHM.
- Learn the basics: what is a hostname.
