Control panels

How to change the server hostname in WHM

Change your cPanel server hostname safely in WHM. Pick a proper FQDN, add its A record, use Change Hostname, then fix the hostname SSL certificate and mail banner.

BeginnerLinux server4 min read

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.com itself;
  • 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.10

If the domain's DNS is hosted on this cPanel server, add the record in Home » DNS Functions » Zone Editor instead.

Wait until it resolves:

Bash
dig +short server.example.com

The 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

  1. Log in to WHM at https://203.0.113.10:2087 as root.
  2. Go to Home » Networking Setup » Change Hostname.
  3. Enter the new FQDN, for example server.example.com.
  4. 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:

Bash
hostname -f

Warning: 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:

Bash
dig +short -x 203.0.113.10

Fix 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:

Bash
/usr/local/cpanel/bin/checkallsslcerts

This 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:

Bash
nc localhost 25

The 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 -f prints the new FQDN.
  • https://server.example.com:2087 loads WHM without a certificate warning.
  • The SMTP banner shows the new name.
  • dig -x on 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 dig and wait.
  • Certificate still shows the old name: AutoSSL has not run yet or failed validation. Run checkallsslcerts again 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

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.