cPanel DNS and Email Recovery on AlmaLinux 9

What this recovery guide fixes
cPanel DNS and email recovery covers the usual support scenario: the server is online, but mail breaks, zones drift, or new domains stop resolving cleanly after a migration or panel change. On AlmaLinux 9, you will use WHM and cPanel tools to repair local DNS records, verify mail routing, rebuild authentication records, and test delivery from both the server and a remote client.
This tutorial is written for a fresh Hostperl VPS or dedicated server running AlmaLinux 9 with cPanel/WHM installed. It is meant for customers who need the server steady for a live website, agency handoff, or email cutover. If you are still choosing infrastructure, Hostperl VPS hosting works well for smaller cPanel workloads, while dedicated server hosting is a better fit for larger mail queues and heavier DNS traffic.
Before you change DNS or mail settings, keep access to the old server or registrar available. DNS mistakes are easy to roll back if you lower TTLs first and change one domain at a time. For broader panel maintenance, the existing cPanel account backups and restore checks guide pairs well with this workflow.
Prerequisites and safe starting point
- AlmaLinux 9 with cPanel/WHM installed and licensed.
- Root SSH access to the server.
- At least one domain already added in cPanel or WHM.
- Access to the domain registrar or DNS provider if nameservers must be changed.
- A second terminal on your local computer for testing after changes.
If your server is still accepting mail on the old host, do not shut it down yet. Keep the old MX live until you have confirmed that the new server receives and sends mail correctly.
Connect to the server and confirm the OS
On your local computer, open a terminal and connect as root. 203.0.113.10 is a reserved documentation address. Replace it with the real public IP assigned to your Hostperl server.
ssh root@203.0.113.10Now confirm that you are on the expected operating system before making any AlmaLinux-specific changes.
cat /etc/os-releaseYou should see AlmaLinux 9 in the output. If you are not on AlmaLinux 9, stop here and follow the equivalent branch for your platform.
Check cPanel service health first
On the VPS as root, confirm that the control panel services are running. A broken service can look like a DNS problem when the real issue is a service outage.
systemctl status cpanel --no-pagerExpected result: the service should be active, or at least cPanel should be present without a failed unit state. If you see a failure, review the journal before changing DNS records.
journalctl -u cpanel -n 50 --no-pagerFor a quick panel-level check, use WHM as well. If the interface loads, you can continue.
Lower DNS TTL before any cutover
DNS changes should move slowly enough to reverse if needed. Lower the TTL for affected records first so you can roll back quickly if you need to restore the previous server.
On the VPS as root, open WHM and edit the zone for the affected domain. If you manage zones from the shell, use the WHM API tool to inspect the zone before changing it.
whmapi1 dumpzone domain=example.comReplace example.com with your real domain. Look for A, MX, TXT, and nameserver records. If the output shows an unexpected IP, you already have a zone drift problem.
When the current TTL is high, reduce it in the DNS zone editor to a short operational value such as 300 seconds. Then wait for the lower TTL to propagate before making record changes.
Repair the zone and nameserver records
Use WHM to correct the basics in the zone file: the root A record, www, mail host, and MX target. If your registrar uses Hostperl nameservers, make sure the registrar also points to the correct nameserver pair.
For a quick validation from the server, query the local resolver and compare it with the authoritative data.
dig example.com A +shortdig example.com MX +shortSuccessful output should show the current server IP for the website and the correct mail exchanger hostname for MX. If the MX still points to the old host, your mail will continue to land there until DNS expires.
If you operate your own authoritative DNS on Hostperl infrastructure, the rent IP address page is relevant when you need clean, stable IP space for nameserver or mail host mapping.
Confirm local mail routing in WHM
Mail routing decides whether the server accepts mail locally or sends it elsewhere. A wrong setting can break inbox delivery even when DNS looks correct.
On the VPS as root, open WHM and go to Email Routing for the domain. If this server hosts the mailbox, choose Local Mail Exchanger. If the mailbox is hosted elsewhere, choose Remote Mail Exchanger.
To confirm the setting from the command line, inspect the domain configuration and Exim status.
/usr/local/cpanel/bin/domainmap --list | grep example.comexim -bP local_interfacesExpected result: the domain should map to this server when mail is local. If the domain is marked remote but the mailbox is here, outbound delivery may still work while inbound mail disappears.
Rebuild SPF, DKIM, and DMARC
Authentication records are a common reason new mail lands in spam after a cutover. Recreate them in the cPanel Email Deliverability interface, then confirm the DNS records match what the panel expects.
Run the built-in check first:
/usr/local/cpanel/bin/dkim_keys_install --helpThen use the Email Deliverability section in WHM to repair the domain. cPanel will generate SPF and DKIM values. Copy those values into DNS if the zone is not managed locally, or let WHM install them if it is.
For verification, query the published records:
dig default._domainkey.example.com TXT +shortdig example.com TXT +short | grep -i spfAdd DMARC as well if it is missing. Start with a conservative policy so you can observe mail flow without blocking legitimate traffic.
cat <<'EOF' > /tmp/dmarc-record.txt
v=DMARC1; p=none; rua=mailto:dmarc@example.com; adkim=s; aspf=s; fo=1
EOFThat file is only a reference for the DNS value. Paste the record into your DNS provider, then confirm it is visible on the public Internet with dig.
Test the mail stack from the server
Once DNS is corrected, test sending from the server itself. This catches Exim problems, bad rDNS, and blocked outbound ports before your users report them.
exim -qffThis forces the queue to process immediately. Then inspect the queue and the log:
exim -bptail -n 50 /var/log/exim_mainlogExpected result: the queue should shrink or stay empty, and the log should show successful deliveries rather than repeated deferrals. If messages are deferred, the log line usually points to the remote SMTP server, DNS, or a policy block.
Send a functional smoke test from a client
On your local computer, test both incoming and outgoing mail with a real mailbox. A DNS record is not enough; you need to see a full round trip.
- Send a message from an external mailbox such as Gmail or Outlook to
you@example.com. - Reply from the cPanel mailbox back to that same external mailbox.
- Check the message headers for SPF, DKIM, and DMARC results.
If you use a mail client, make sure it connects over the correct submission port and authenticated SMTP. If delivery fails only for one provider, review that provider's rejection message before changing server settings.
Lock down the panel after recovery
After mail and DNS are working again, remove any temporary exposure you opened during troubleshooting. Keep the sequence simple: test first, then tighten access.
On AlmaLinux 9, firewalld is usually active. Confirm the required service ports are available before touching anything else.
firewall-cmd --list-servicescPanel commonly uses ports such as 2083, 2087, 2095, 2096, 25, 465, 587, 53, and 80/443 depending on the setup. If you made a temporary firewall exception, remove it only after the final tests pass.
If you need to view the active zones and rules, run:
firewall-cmd --get-active-zonesFor DNS changes, keep the lower TTL in place until you are confident the cutover has held for at least one full propagation window. Then return it to a more normal value.
Roll back if the cutover fails
If mail starts breaking after the change, do not keep guessing. Roll back the DNS records to the previous working host while the lower TTL is still in effect.
On the VPS as root, re-open the zone and restore the previous MX, A, and mail routing values. Then re-run:
dig example.com MX +shortUse the old server or previous provider until you confirm inbound mail resumes. If the issue is local to cPanel, compare the current zone file to a known-good backup and restore from backup if needed. The backup recovery workflow in MariaDB backups and restores that hold up in 2026 is a useful companion if your mail platform also depends on database-backed applications.
Troubleshooting the most likely failures
1. Mail arrives on the old server.
Run dig example.com MX +short. If it still shows the old host, your MX has not propagated or was edited in the wrong zone. Correct the authoritative DNS zone and wait for TTL expiry.
2. Outgoing mail is rejected.
Run tail -n 50 /var/log/exim_mainlog. If you see SPF, DKIM, or rDNS failures, repair the authentication records and confirm the server hostname and PTR match.
3. cPanel service pages are slow or failing.
Run systemctl status cpanel --no-pager and journalctl -u cpanel -n 50 --no-pager. The journal usually shows the real cause, such as a resource issue or a failed internal service.
4. DNS looks correct but mail still bounces.
Check firewall and queue status with firewall-cmd --list-services and exim -bp. A blocked outbound port or stuck queue can look like a DNS fault from the outside.
Final verification checklist
systemctl status cpanel --no-pagershows the panel active.dig example.com MX +shortreturns the correct mail host.dig default._domainkey.example.com TXT +shortreturns a DKIM record.exim -bpshows no unexpected queue buildup.- A test message sends and receives successfully from an external mailbox.
When those checks pass, your DNS and email cutover is complete. If this server will host more than one customer domain, consider pairing it with Hostperl dedicated server hosting for better isolation and headroom, or managed VPS hosting if you want a smaller cPanel footprint with predictable support. For additional panel hygiene, the cPanel account backups and restore checks article is the next step.
If your cPanel server is handling live mailboxes, domain migrations, or agency handoffs, Hostperl can keep the underlying platform predictable while you fix the records that matter. Start with a Hostperl VPS for smaller accounts or move to dedicated server hosting when you need more isolation, storage, and mail throughput.
That gives you a clean base for DNS repairs, mail authentication, and restore testing without adding more risk to the cutover.
FAQ
Why does cPanel mail work on one domain but fail on another?
Usually the zones differ. Compare the MX, SPF, and DKIM records for both domains, then check their cPanel email routing settings.
Should I change DNS and email at the same time?
Only if you have to. The safer pattern is to lower TTL, confirm DNS propagation, then switch mail routing and authentication records in a controlled order.
How long should I keep the old server online after cutover?
Keep it online until inbound and outbound mail have both passed testing and the TTL window has expired. That gives you a clean rollback path if users report a problem later.
What if DKIM is correct but mail still lands in spam?
Check PTR, SPF alignment, sender reputation, and the content of the test message. A correct DKIM record does not guarantee inbox placement on its own.
Can I use this guide for a managed migration?
Yes. It fits the final validation phase of a managed handoff, especially when the provider has already copied accounts and you are only fixing DNS and email delivery.
