I had a support ticket submitted detailing a problem with a user not being able to log into a website. Strangely enough, the error shown in the browser when trying to log in was “Too many redirects”. The rest of the website was working as expected.
Digging into the server logs, I could not find anything relating to the issue. The usual, and expected, hack attempts but nothing indicating why the login page would redirect to whatever…
Further investigation has shown that the hosting account was unexpectedly sitting at 113% disk usage. There are only two things that will cause that. The site is hacked and something uploaded, or one of the email accounts has a huge amount of emails in a folder somewhere.
I was pretty sure the site was not hacked so checking the email accounts, it turned out that the cPanel default email account has a total of 1,001Mb of something in it. Checking the account, there were only 80 emails and the total was nowhere close to what was reported.
The cPanel default email account is created automatically and usually not used by anyone. Most domains receive email messages for invalid or nonexistent email addresses on the domain as a result of typos or something similar.
Disk usage is calculated based on several reports from various sections of the account. The actual file system, the MySql database, and the email accounts amongst others.
What happened here was that the report for the email account totals were corrupt and not reporting the correct values resulting in the server “thinking” that the account was overused.
First I increased the account disk space to allow the website to work as intended.
After unsuccessfully trying various different methods, it was time to tackle this thing head-on.
The following is the solution to clearing out the “reports” from the various email accounts total disk space. This only works if you have root access. Something the average user would not have for safety and security reasons.
Step 1: SSH to the server as the root user.
Step 2: Execute the following script.
/scripts/generate_maildirsize --confirm --allaccounts --verbose cpaneluser
Replacing “cpaneluser” with the cPanel user-name
You will see something like this returned;
Rebuilding the maildirsize files for: cpaneluser Rebuilding the maildirsize files for: firstname.lastname@example.org Checking user cpaneluser Calculating diskusage and diskcount from reading files Writing /home/cpaneluser/mail/maildirsize for user cpaneluser Checking user email@example.com Calculating diskusage and diskcount from reading files Writing /home/cpaneluser/mail/my-domain.com/john_doe/maildirsize for user john_doe
Admittedly not very useful in understanding what it is actually doing. In essence, it is checking the actual email sizes and recalculating the total size. Then writing it back into the “report”
Step 3: Log back into the cPanel account and verify that the disk usage is as expected.
I hope this would be helpful to someone else in the same position. Remember to set the account disk space back to the desired size when you are done.