Read only
Every query below is a SELECT. It changes nothing. Run it in phpMyAdmin or the mysql client, on a copy of the database if you have one.
WHMCS guide
A missing invoice makes no noise: the client is not chased, nothing shows as overdue and the service keeps running. On one of our own installs the first query below found four active add-ons whose last due date was in 2016 to 2018, with no invoice anyone could pay.
DMS.S2 — Before you start
Every query below is a SELECT. It changes nothing. Run it in phpMyAdmin or the mysql client, on a copy of the database if you have one.
Only active, recurring items with a price are listed, and domains set to Do Not Renew stay out. A cancelled invoice does not count as something to pay.
We ran each query on a test database with rows that should match and rows that should not: an open invoice, a Payment Pending renewal, a free add-on, a suspended service, a one-time product. Queries 2 and 3 return nothing on our two live installs.
DMS.S3 — The queries
Active and past due, but no Unpaid or Payment Pending invoice for the item. Usually the invoice was deleted or cancelled: WHMCS does not create a second invoice for a due date it already invoiced. If the invoice is Paid, see the suspended-after-paying guide instead.
SELECT 'service' AS kind, h.id, h.userid, h.domain AS item, h.nextduedate, h.amount
FROM tblhosting h
WHERE h.domainstatus = 'Active' AND h.amount > 0
AND h.billingcycle NOT IN ('Free Account', 'One Time')
AND h.nextduedate > '1000-01-01' AND h.nextduedate < CURDATE()
AND NOT EXISTS (SELECT 1 FROM tblinvoiceitems ii JOIN tblinvoices i ON i.id = ii.invoiceid
WHERE ii.type = 'Hosting' AND ii.relid = h.id
AND i.status IN ('Unpaid', 'Payment Pending'))
UNION ALL
SELECT 'addon', a.id, a.userid, a.name, a.nextduedate, a.recurring
FROM tblhostingaddons a
WHERE a.status = 'Active' AND a.recurring > 0
AND a.billingcycle NOT IN ('Free', 'Free Account', 'One Time', 'onetime')
AND a.nextduedate > '1000-01-01' AND a.nextduedate < CURDATE()
AND NOT EXISTS (SELECT 1 FROM tblinvoiceitems ii JOIN tblinvoices i ON i.id = ii.invoiceid
WHERE ii.type = 'Addon' AND ii.relid = a.id
AND i.status IN ('Unpaid', 'Payment Pending'))
UNION ALL
SELECT 'domain', d.id, d.userid, d.domain, d.nextduedate, d.recurringamount
FROM tbldomains d
WHERE d.status = 'Active' AND d.donotrenew = 0 AND d.recurringamount > 0
AND d.nextduedate > '1000-01-01' AND d.nextduedate < CURDATE()
AND NOT EXISTS (SELECT 1 FROM tblinvoiceitems ii JOIN tblinvoices i ON i.id = ii.invoiceid
WHERE ii.type IN ('Domain', 'DomainRegister', 'DomainRenew', 'DomainTransfer')
AND ii.relid = d.id AND i.status IN ('Unpaid', 'Payment Pending'));
An import, a manual edit or the API left the date empty. The cron bills by that date, so the item is never invoiced and never shows as overdue either.
SELECT 'service' AS kind, id, userid, domain AS item, amount
FROM tblhosting
WHERE domainstatus = 'Active' AND amount > 0
AND billingcycle NOT IN ('Free Account', 'One Time')
AND (nextduedate IS NULL OR nextduedate < '1000-01-01')
UNION ALL
SELECT 'addon', id, userid, name, recurring
FROM tblhostingaddons
WHERE status = 'Active' AND recurring > 0
AND billingcycle NOT IN ('Free', 'Free Account', 'One Time', 'onetime')
AND (nextduedate IS NULL OR nextduedate < '1000-01-01')
UNION ALL
SELECT 'domain', id, userid, domain, recurringamount
FROM tbldomains
WHERE status = 'Active' AND donotrenew = 0 AND recurringamount > 0
AND (nextduedate IS NULL OR nextduedate < '1000-01-01');
2062 typed for 2026: the cron will not reach that date for decades, so the client uses the service for free until someone notices.
SELECT 'service' AS kind, id, userid, domain AS item, nextduedate, amount
FROM tblhosting
WHERE domainstatus = 'Active' AND amount > 0
AND billingcycle NOT IN ('Free Account', 'One Time')
AND nextduedate > CURDATE() + INTERVAL 5 YEAR
UNION ALL
SELECT 'addon', id, userid, name, nextduedate, recurring
FROM tblhostingaddons
WHERE status = 'Active' AND recurring > 0
AND billingcycle NOT IN ('Free', 'Free Account', 'One Time', 'onetime')
AND nextduedate > CURDATE() + INTERVAL 5 YEAR;
DMS.S4 — The addon
Brasa Billing Audit runs these checks with the rest of its billing checks, links each finding to the service or domain and e-mails admins when a new one appears. It never creates an invoice or changes a due date.

$39 per year
Finds the billing records that do not add up.
DMS.S5 — Questions
The daily cron invoices by the next due date on each service, add-on and domain. It skips items that are not Active, items with no due date or a date far ahead, and a due date it already invoiced even if that invoice was later deleted. Also check under Utilities > Automation Status that the cron runs every day.
Correct the next due date on the service, add-on or domain and save. Then open the client Summary tab and click Generate Due Invoices. If WHMCS already invoiced that date and the invoice was deleted, set the date one day earlier, as the WHMCS documentation advises.
That is a decision for you and the client, not for the query. Often the add-on is no longer in use and the right fix is to cancel it, so it stops showing as active.
DMS.S6 — Start a project
Tell us how it was set up. If other hosts would hit it, it may become a check.