1

Topic: Logging into iRedadmin Pro - slow and gateway erros

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.6.8
- Deployed with iRedMail Easy or the downloadable installer? downloadable installer
- Linux/BSD distribution name and version: Rocky 8
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? Yes, we are on 5.6
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Logging into iRedadmin Pro has always taken some time but many times, we can't logon and get gateway errors as we logon or it takes users 3 minutes or so to logon.

Just wondering if there are things we can check such as settings/config that would be responsible for this. We are on MariaDB 10.3.39. Our email servers are in our California Data Center where I believe that most of use are going through our Michigan Data Center to get there, that link is a 1gb link.

We do have plans for moving this email server over to Michigan and then update to iRedmail EE and even run a new version of MariaDB on a remote server (LDAP will still be our backend and will run that remotely also as we do today).

If there are things that we could do now that could help, I appreciate any input you all might have.

Thanks. Scott.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Logging into iRedadmin Pro - slow and gateway erros

- How many records do you have in SQL table "amvaisd.msgs"?
- Do you have cron job to run `/opt/www/iredadmin/tools/cleanup_amavisd_db.py` every X hours?

You can run it manually to clean up data:

python3 /opt/www/iredadmin/tools/cleanup_amavisd_db.py

- I see you have an iRedMail Enterprise Edition ("EE" for short) license running, are we talking about EE server or iRedMail server deployed with downloadable shell installer?
- Any plan to migrate to EE shortly?

3

Re: Logging into iRedadmin Pro - slow and gateway erros

Zhang, thanks for your response.

We currently have a count(*) of 366,172 in amavaisd.msgs.
Based on that number, we probably don't have that cleanup job running.

We do have an iRedmail EE license but have not migrated yet, but are hopeful and excited to move over to iRedmail EE. As for when, it will still be a at least a few months out. We have some other email related things before we get to this migration.

Thanks. Scott.

4

Re: Logging into iRedadmin Pro - slow and gateway erros

Please run this command manually to clean up data:

python3 /opt/www/iredadmin/tools/cleanup_amavisd_db.py

How long do you set to keep the amavisd db data? It's printed on the output of above command.

5

Re: Logging into iRedadmin Pro - slow and gateway erros

Zhang, it turns out we are running that cleanup daily:
# iRedMail: Cleanup Amavisd database
1   2   *   *   *   /usr/bin/python3 /opt/www/iredadmin/tools/cleanup_amavisd_db.py >/dev/null

But we are running it manually right now. Here is the output at the beginning:
* Delete quarantined mails which older than 7 days
*       [-] Deleting records: 1 - 1 (Tue Mar 17 11:39:12 2026)
* Delete incoming/outgoing emails which older than 7 days

Job finished running, here is the final output
*
* Remained records:
*
*       `msgs`: 352213
* `quarantine`: 6     
*      `maddr`: 123677
*   `mailaddr`: 60     
* Log cleanup status.

One theory we have is that sql is potentially causing this issue with the writes and that is why we wanted to have sql hosted remotely. We are also building a new mailstore server and bringing mail over to our MI datacenter, both could help with performance. After those, we want to migrate to iRed EE and perhaps we will start using MariaDB as our backend instead of LDAP and then we can have MariaDB remote also.

One other question, once we do build an iRedmail EE server with Ubuntu 24.04, what version of MariaDB should we go with? Can we go with 11.8, is that supported? I know most of the repos still have 10.11.14.

Thanks again Zhang!

6

Re: Logging into iRedadmin Pro - slow and gateway erros

squigley wrote:

* Delete incoming/outgoing emails which older than 7 days

Try to decrease the time of keeping info of incoming/outgoing emails by appending this line in /opt/www/iredadmin/settings.py (you should already have this parameter but set to different value, because default value is 3 and you now have 7):

AMAVISD_REMOVE_MAILLOG_IN_DAYS = 3
squigley wrote:

One theory we have is that sql is potentially causing this issue with the writes and that is why we wanted to have sql hosted remotely.

These records should not cause SQL performance issue (with a local MariaDB server) at all, and OpenLDAP backend doesn't matter either.

squigley wrote:

One other question, once we do build an iRedmail EE server with Ubuntu 24.04, what version of MariaDB should we go with? Can we go with 11.8, is that supported? I know most of the repos still have 10.11.14.

Just use the one offered by Ubuntu official apt repository, don't use a remote SQL server if possible.

7

Re: Logging into iRedadmin Pro - slow and gateway erros

On that amavis setting, we have the following in /libs/default_settings.py

# Remove old SQL records of sent/received mails in Amavisd database.
# NOTE: require cron job with script tools/cleanup_amavisd_db.py.
AMAVISD_REMOVE_MAILLOG_IN_DAYS = 3

When I check /opt/www/iredamin/settings.py for any overrides, I do not find that setting at all so I am unsure why our output said 7 days.

On the remote MariaDB question, even though iRed EE does support using remote MariaDB as your backend are you saying it is better to keep it local and not remote?

Thanks again. Scott.

8

Re: Logging into iRedadmin Pro - slow and gateway erros

Here is an update. To make iRedadmin load better we did the following as you had recommended in another post:

Set "REDIRECT_TO_DOMAIN_LIST_AFTER_LOGIN = True" in iRedAdmin-Pro config file will redirect you to "Domains and Accounts" page after login.

On that that AMAVISD_REMOVE_MAILLOG_IN_DAYS = 3 setting which we had in default_settings.py and were not overriding in /iredadmin/settings.py, not sure why we had 7 and not 3.

Initially, I looked at the settings table in iredadmin and it was empty to I re-saved the settings and now those settings were in the table including AMAVISD_REMOVE_MAILLOG_IN_DAYS = 3 so once the cleanup runs at 2am we shall see.

The iRedadmin logon is much faster, it appears that Dashboard was causing our issues.

9

Re: Logging into iRedadmin Pro - slow and gateway erros

squigley wrote:

On that that AMAVISD_REMOVE_MAILLOG_IN_DAYS = 3 setting which we had in default_settings.py and were not overriding in /iredadmin/settings.py, not sure why we had 7 and not 3.

Please login to iRedAdmin-Pro as global admin, then click `System` -> `Settings`, find section `Data Clean Up`, set the days here, then run command `python3 /opt/www/iredadmin/tools/cleanup_amavisd_db.py` again.

squigley wrote:

On the remote MariaDB question, even though iRed EE does support using remote MariaDB as your backend are you saying it is better to keep it local and not remote?

Local SQL server has (a lot) better performance.

10 (edited by squigley Yesterday 21:16:01)

Re: Logging into iRedadmin Pro - slow and gateway erros

Zhang, we made that change in the settings, and let cron run the cleanup job at 2am. I will attach the screenshot below. Also, when I run a count(*) by day on msgs in amavaisd, here is what I get:

+------------+-----------+
| day        | msg_count |
+------------+-----------+
| 2026-03-19 |      7876 |
| 2026-03-18 |     58657 |
| 2026-03-17 |     63114 |
| 2026-03-16 |     65047 |
| 2026-03-15 |     15518 |
| 2026-03-14 |     24824 |
| 2026-03-13 |     57453 |
| 2026-03-12 |     61969 |
+------------+-----------+

Not sure why we can't get 3 days to stick.

Also, is it known that when loading iRedadmin to the Dashboard, that can cause timeout issues with all the work its doing?

11

Re: Logging into iRedadmin Pro - slow and gateway erros

- If some task takes too long (longer than http session), it may cause timeout.
- You can run command `python3 /opt/www/iredadmin/tools/cleanup_amavisd_db.py` manually, no need to wait for cron.

12

Re: Logging into iRedadmin Pro - slow and gateway erros

Zhang, we made those changes to that amavis setting before the 2am cron job and after it ran, it appears we still have 7 days of msgs and not 3. Here is what the settings table looks like:
MariaDB [iredadmin]> select * from settings;
+----+---------+------------------------------------+----------------------+
| id | account | k                                  | v                    |
+----+---------+------------------------------------+----------------------+
|  1 | global  | restful_api_clients                | {"value": []}        |
|  2 | global  | min_passwd_length                  | {"value": "8"}       |
|  3 | global  | mailbox_format                     | {"value": "maildir"} |
|  4 | global  | global_admin_ip_list               | {"value": []}        |
|  5 | global  | password_has_uppercase             | {"value": true}      |
|  6 | global  | password_has_number                | {"value": true}      |
|  7 | global  | admin_login_ip_list                | {"value": []}        |
|  8 | global  | password_has_letter                | {"value": true}      |
|  9 | global  | amavisd_remove_quarantined_in_days | {"value": "7"}       |
| 10 | global  | amavisd_remove_maillog_in_days     | {"value": "3"}       |
| 11 | global  | mailbox_folder                     | {"value": "Maildir"} |
| 12 | global  | password_has_special_char          | {"value": true}      |
+----+---------+------------------------------------+----------------------+

Do we need to restart amavis for this to work?