1

Topic: web GUI is down: error 502 Bad Gateway

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.7.1 MariaDB
- Deployed with iRedMail Easy or the downloadable installer? installer
- Linux/BSD distribution name and version: Ubuntu 24.04 LTS
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
Good evening,
after running and updating over years (Ubuntu18 => 20 => 22 => 24), I get following issue that I can not fix:
I noticed "accidentally" today that the management web GUI (server.domain.tld/iredadmin) of my server is down and returns "502 Badgateway  nginx".

SOGo is running well (with clients and via webGUI), email jobs are running well too. Only the admin GUI is broken.

Weeks (months?) ago, I updated Ubuntu 22 => 24 without noticed issue. This tuto docs.iredmail.org/upgrade.ubuntu.22.04-24.04 was not available at this time (or I didn't see it). I can't say when exactly the issue appears. I'm not 100% sure having tested the WebGUI after the upgrade.

Today I follow the tuto, hoping it would solve the problem but unfortunately it didn't and in addition adds new problems (massive error emails were generated). I hadn't the time to inspect them, so I rolled back the status before the tuto (the server iredmail is a VM) to get the normal mails jobs running again.

What I tried / noticed:
- nginx is running

systemctl status nginx

- running version of php:

# php -v
PHP 8.3.6 (cli) (built: Dec  2 2024 12:36:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies 

- php seems to run

# systemctl status php8.3-fpm 

So, could somebody put me in the right direction?
Thanks.
Bye Arnaud

PS: I was not able to post the complete return to the systemctl status into the post: too much links...Why?

----

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

2

Re: web GUI is down: error 502 Bad Gateway

I don't know exactly why, but I "think" there is something wrong with php-fpm....

Looking once again at the tuto for upgrade Ubuntu 22 => 24, I noticed that:
- the tuto gives "Override file /etc/nginx/conf-available/php - fpm.conf with content below:..." phpMINUSfpm
- my server has /etc/nginx/conf-available/php _ fpm.conf phpUNDERSCOREfpm
and the file of the server already has the content given by the tuto.

Bye Arnaud

3 (edited by arnaud056 2025-02-07 16:42:42)

Re: web GUI is down: error 502 Bad Gateway

good morning,
on an other VM, I created a fresh installation of Ubuntu24 + iRedMail 1.7.2 (MariaDB + nginx + SOGo) and after the last reboot there is the same problem that I have with the "production" installation: "/IP/iredadmin" gives 502 Bad Gateway nginx

=> it seems to be a general problem with Ubuntu24. I think that this issue can be reproduced because it  comes before making any specific configs.
Could somebody confirm? 

EDIT: Debian12 + iRedMail 1.7.2 (MariaDB + nginx + SOGo) runs OK


Bye Arnaud

4

Re: web GUI is down: error 502 Bad Gateway

- Is "iredadmin" service running?
- Any related error in /var/log/syslog when it raises this error?

Also, run commands below and show us full console output:

apt -y install python3-cheroot
cd /opt/www/iredadmin/
python3 iredadmin.py

5

Re: web GUI is down: error 502 Bad Gateway

Good morning,
you are right: service iredamin is down:

# systemctl status iredadmin
× iredadmin.service - iRedAdmin daemon service
     Loaded: loaded (/usr/lib/systemd/system/iredadmin.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Sat 2025-02-08 10:25:52 CET; 1min 14s ago
   Duration: 1.399s
    Process: 239 ExecStartPre=/bin/mkdir -p /var/run/iredadmin (code=exited, status=0/SUCCESS)
    Process: 301 ExecStartPre=/bin/chown iredadmin:iredadmin /var/run/iredadmin (code=exited, status=0/SUCCESS)
    Process: 323 ExecStartPre=/bin/chmod 0755 /var/run/iredadmin (code=exited, status=0/SUCCESS)
    Process: 346 ExecStart=/usr/bin/uwsgi --ini /opt/www/iredadmin/rc_scripts/uwsgi/debian.ini --pidfile /var/run/iredadmin/iredadmin.pid (code=exited, status=1/FAILURE)
    Process: 381 ExecStopPost=/bin/rm -rf /var/run/iredadmin (code=exited, status=0/SUCCESS)
   Main PID: 346 (code=exited, status=1/FAILURE)
        CPU: 156ms

Feb 08 10:25:51 mail-ct2 iredadmin[346]: setgid() to 2001
Feb 08 10:25:51 mail-ct2 iredadmin[346]: setuid() to 2001
Feb 08 10:25:51 mail-ct2 iredadmin[346]: chdir() to /opt/www/iredadmin
Feb 08 10:25:51 mail-ct2 iredadmin[346]: your processes number limit is 95775
Feb 08 10:25:51 mail-ct2 iredadmin[346]: your memory page size is 4096 bytes
Feb 08 10:25:51 mail-ct2 iredadmin[346]: detected max file descriptor number: 1024
Feb 08 10:25:51 mail-ct2 iredadmin[346]: VirtualHosting mode enabled.
Feb 08 10:25:51 mail-ct2 iredadmin[346]: lock engine: pthread robust mutexes
Feb 08 10:25:51 mail-ct2 iredadmin[346]: thunder lock: disabled (you can enable it with --thunder-lock)
Feb 08 10:25:51 mail-ct2 iredadmin[346]: socket(): Permission denied [core/socket.c line 82]

"python3 iredadmin.py" stucks:

# python3 iredadmin.py
"h-t-t-p"://0.0.0.0:8080/ 

Running it again:

# python3 iredadmin.py
"http"://0.0.0.0:8080/
Traceback (most recent call last):
  File "/opt/www/iRedAdmin-2.6/iredadmin.py", line 16, in <module>
    app.run()
  File "/opt/www/iRedAdmin-2.6/web/application.py", line 357, in run
    return wsgi.runwsgi(self.wsgifunc(*middleware))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/www/iRedAdmin-2.6/web/wsgi.py", line 66, in runwsgi
    return httpserver.runsimple(func, server_addr)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/www/iRedAdmin-2.6/web/httpserver.py", line 163, in runsimple
    server.start()
  File "/usr/lib/python3/dist-packages/cheroot/server.py", line 1840, in start
    self.prepare()
  File "/usr/lib/python3/dist-packages/cheroot/server.py", line 1795, in prepare
    raise socket.error(msg)
OSError: No socket could be created -- (('0.0.0.0', 8080): [Errno 98] Address already in use)

/var/log/syslog is not showing error messages.

Thanks for your help!
Bye Arnaud

6

Re: web GUI is down: error 502 Bad Gateway

It says "Permission denied". is port 7791 used by another iRedAdmin process (or another program)?

Feb 08 10:25:51 mail-ct2 iredadmin[346]: socket(): Permission denied [core/socket.c line 82]

What's the related log lines in /var/log/syslog right after restarting iredadmin service?

7 (edited by arnaud056 2025-02-10 03:47:42)

Re: web GUI is down: error 502 Bad Gateway

Good evening,

if I'm right, port 7791 is not in use:

# netstat -tulpn | grep 7791
root@mail-ct2:~# 

.

7777, 7778 and 7779 are in use by python3:

# netstat -tulpn | grep 777
tcp        0      0 127.0.0.1:7779          0.0.0.0:*               LISTEN      1060/python3        
tcp        0      0 127.0.0.1:7778          0.0.0.0:*               LISTEN      1060/python3        
tcp        0      0 127.0.0.1:7777          0.0.0.0:*               LISTEN      1060/python3  

Without the "grep" I can see all and of course 7791 is missing.

I restarted (systemctl restart iredadmin) iredadmin at 20:32.

Here the logs from /var/log/syslog:

2025-02-09T20:31:01.244000+01:00 mail-ct2 CRON[1821]: (sogo) CMD (/usr/sbin/sogo-tool expire-sessions 30 >/dev/null 2>&1; /usr/sbin/sogo-ealarms-notify >/dev/null 2>&1)
2025-02-09T20:31:39.760583+01:00 mail-ct2 systemd[893]: launchpadlib-cache-clean.service - Clean up old files in the Launchpadlib cache was skipped because of an unmet condition check (ConditionPathExists=/root/.launchpadlib/api.launch>
2025-02-09T20:32:01.230475+01:00 mail-ct2 CRON[1845]: (root) CMD (/bin/bash /usr/local/bin/fail2ban_banned_db unban_db)
2025-02-09T20:32:01.231186+01:00 mail-ct2 CRON[1846]: (sogo) CMD (/usr/sbin/sogo-tool expire-sessions 30 >/dev/null 2>&1; /usr/sbin/sogo-ealarms-notify >/dev/null 2>&1)
2025-02-09T20:32:02.557473+01:00 mail-ct2 systemd[1]: Starting iredadmin.service - iRedAdmin daemon service...
2025-02-09T20:32:02.763631+01:00 mail-ct2 systemd[1]: Started iredadmin.service - iRedAdmin daemon service.
2025-02-09T20:32:02.828701+01:00 mail-ct2 uwsgi[1867]: [uWSGI] getting INI configuration from /opt/www/iredadmin/rc_scripts/uwsgi/debian.ini
2025-02-09T20:32:02.844961+01:00 mail-ct2 iredadmin: *** Starting uWSGI 2.0.24-debian (64bit) on [Sun Feb  9 20:32:02 2025] ***
2025-02-09T20:32:02.849573+01:00 mail-ct2 iredadmin: compiled with version: 13.2.0 on 17 April 2024 16:23:48
2025-02-09T20:32:02.852700+01:00 mail-ct2 systemd[1]: iredadmin.service: Main process exited, code=exited, status=1/FAILURE
2025-02-09T20:32:02.853185+01:00 mail-ct2 iredadmin: os: Linux-6.8.12-7-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-7 (2025-01-17T08:18Z)
2025-02-09T20:32:02.853366+01:00 mail-ct2 iredadmin: nodename: mail-ct2
2025-02-09T20:32:02.853658+01:00 mail-ct2 iredadmin: machine: x86_64
2025-02-09T20:32:02.853791+01:00 mail-ct2 iredadmin: clock source: unix
2025-02-09T20:32:02.853904+01:00 mail-ct2 iredadmin: pcre jit disabled
2025-02-09T20:32:02.854017+01:00 mail-ct2 iredadmin: detected number of CPU cores: 1
2025-02-09T20:32:02.854131+01:00 mail-ct2 iredadmin: current working directory: /
2025-02-09T20:32:02.854256+01:00 mail-ct2 iredadmin: writing pidfile to /var/run/iredadmin/iredadmin.pid
2025-02-09T20:32:02.858905+01:00 mail-ct2 iredadmin: detected binary path: /usr/bin/uwsgi-core
2025-02-09T20:32:02.859242+01:00 mail-ct2 iredadmin: setgid() to 2001
2025-02-09T20:32:02.859497+01:00 mail-ct2 iredadmin: setuid() to 2001
2025-02-09T20:32:02.859783+01:00 mail-ct2 iredadmin: chdir() to /opt/www/iredadmin
2025-02-09T20:32:02.860045+01:00 mail-ct2 iredadmin: your processes number limit is 95775
2025-02-09T20:32:02.860270+01:00 mail-ct2 iredadmin: your memory page size is 4096 bytes
2025-02-09T20:32:02.860534+01:00 mail-ct2 iredadmin: detected max file descriptor number: 1024
2025-02-09T20:32:02.860850+01:00 mail-ct2 iredadmin: VirtualHosting mode enabled.
2025-02-09T20:32:02.861113+01:00 mail-ct2 iredadmin: lock engine: pthread robust mutexes
2025-02-09T20:32:02.864153+01:00 mail-ct2 iredadmin: thunder lock: disabled (you can enable it with --thunder-lock)
2025-02-09T20:32:02.864421+01:00 mail-ct2 iredadmin: socket(): Permission denied [core/socket.c line 82]
2025-02-09T20:32:02.905403+01:00 mail-ct2 systemd[1]: iredadmin.service: Failed with result 'exit-code'.
2025-02-09T20:33:00.802550+01:00 mail-ct2 PackageKit: daemon quit
2025-02-09T20:33:00.817108+01:00 mail-ct2 systemd[1]: packagekit.service: Deactivated successfully.
 

and once again at 20:40:

2025-02-09T20:39:01.605929+01:00 mail-ct2 CRON[2228]: (root) CMD (  [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
2025-02-09T20:39:01.616588+01:00 mail-ct2 CRON[2229]: (sogo) CMD (/usr/sbin/sogo-tool expire-sessions 30 >/dev/null 2>&1; /usr/sbin/sogo-ealarms-notify >/dev/null 2>&1)
2025-02-09T20:40:00.037119+01:00 mail-ct2 systemd[1]: Starting sysstat-collect.service - system activity accounting tool...
2025-02-09T20:40:00.129529+01:00 mail-ct2 systemd[1]: sysstat-collect.service: Deactivated successfully.
2025-02-09T20:40:00.130627+01:00 mail-ct2 systemd[1]: Finished sysstat-collect.service - system activity accounting tool.
2025-02-09T20:40:01.717417+01:00 mail-ct2 CRON[2256]: (root) CMD (/bin/bash /usr/local/bin/fail2ban_banned_db unban_db)
2025-02-09T20:40:01.722498+01:00 mail-ct2 CRON[2257]: (sogo) CMD (/usr/sbin/sogo-tool expire-sessions 30 >/dev/null 2>&1; /usr/sbin/sogo-ealarms-notify >/dev/null 2>&1)
2025-02-09T20:40:02.720263+01:00 mail-ct2 systemd[1]: Starting iredadmin.service - iRedAdmin daemon service...
2025-02-09T20:40:03.008324+01:00 mail-ct2 systemd[1]: Started iredadmin.service - iRedAdmin daemon service.
2025-02-09T20:40:03.171636+01:00 mail-ct2 uwsgi[2278]: [uWSGI] getting INI configuration from /opt/www/iredadmin/rc_scripts/uwsgi/debian.ini
2025-02-09T20:40:03.222419+01:00 mail-ct2 iredadmin: *** Starting uWSGI 2.0.24-debian (64bit) on [Sun Feb  9 20:40:03 2025] ***
2025-02-09T20:40:03.234114+01:00 mail-ct2 iredadmin: compiled with version: 13.2.0 on 17 April 2024 16:23:48
2025-02-09T20:40:03.234268+01:00 mail-ct2 iredadmin: os: Linux-6.8.12-7-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-7 (2025-01-17T08:18Z)
2025-02-09T20:40:03.234382+01:00 mail-ct2 iredadmin: nodename: mail-ct2
2025-02-09T20:40:03.237728+01:00 mail-ct2 iredadmin: machine: x86_64
2025-02-09T20:40:03.238173+01:00 mail-ct2 iredadmin: clock source: unix
2025-02-09T20:40:03.238317+01:00 mail-ct2 iredadmin: pcre jit disabled
2025-02-09T20:40:03.238535+01:00 mail-ct2 iredadmin: detected number of CPU cores: 1
2025-02-09T20:40:03.238736+01:00 mail-ct2 iredadmin: current working directory: /
2025-02-09T20:40:03.238864+01:00 mail-ct2 iredadmin: writing pidfile to /var/run/iredadmin/iredadmin.pid
2025-02-09T20:40:03.238973+01:00 mail-ct2 iredadmin: detected binary path: /usr/bin/uwsgi-core
2025-02-09T20:40:03.239082+01:00 mail-ct2 iredadmin: setgid() to 2001
2025-02-09T20:40:03.239190+01:00 mail-ct2 iredadmin: setuid() to 2001
2025-02-09T20:40:03.239295+01:00 mail-ct2 iredadmin: chdir() to /opt/www/iredadmin
2025-02-09T20:40:03.262716+01:00 mail-ct2 iredadmin: your processes number limit is 95775
2025-02-09T20:40:03.265967+01:00 mail-ct2 systemd[1]: iredadmin.service: Main process exited, code=exited, status=1/FAILURE
2025-02-09T20:40:03.266131+01:00 mail-ct2 iredadmin: your memory page size is 4096 bytes
2025-02-09T20:40:03.266237+01:00 mail-ct2 iredadmin: detected max file descriptor number: 1024
2025-02-09T20:40:03.266354+01:00 mail-ct2 iredadmin: VirtualHosting mode enabled.
2025-02-09T20:40:03.277575+01:00 mail-ct2 iredadmin: lock engine: pthread robust mutexes
2025-02-09T20:40:03.277815+01:00 mail-ct2 iredadmin: thunder lock: disabled (you can enable it with --thunder-lock)
2025-02-09T20:40:03.277936+01:00 mail-ct2 iredadmin: socket(): Permission denied [core/socket.c line 82]
2025-02-09T20:40:03.368302+01:00 mail-ct2 systemd[1]: iredadmin.service: Failed with result 'exit-code'.
2025-02-09T20:40:49.324646+01:00 mail-ct2 systemd[1]: Starting systemd-tmpfiles-clean.service - Cleanup of Temporary Directories...
2025-02-09T20:40:49.476037+01:00 mail-ct2 systemd[1]: systemd-tmpfiles-clean.service: Deactivated successfully.
2025-02-09T20:40:49.477509+01:00 mail-ct2 systemd[1]: Finished systemd-tmpfiles-clean.service - Cleanup of Temporary Directories.

Can you reproduce the issue on a fresh Ubuntu24.04?

Bye Arnaud

8

Re: web GUI is down: error 502 Bad Gateway

arnaud056 wrote:

Can you reproduce the issue on a fresh Ubuntu24.04?

No issue with fresh Ubuntu 24.04 + iRedMail-1.7.2.
I think there's something wrong on your server since it reports "Permission denied".
Could you please re-download latest iRedAdmin(-Pro) and upgrade? Let's see how it works.

9

Re: web GUI is down: error 502 Bad Gateway

ZhangHuangbin wrote:

No issue with fresh Ubuntu 24.04 + iRedMail-1.7.2

hhmmm!!!
I just have downloaded a new LXC-container (Proxmox) of Ubuntu 24.04, have installed it, run all the updates and have token the current 1.7.2.tar.gz => same result: 502 BadGateway. SOGo is OK.
I couldn't se any error during the installation.

Could LXC be suddenly the cause of the problem?

I think it is time for me to IMAP sync the emails of the "production" system (another LXC container running Ubuntu for years now).....

10

Re: web GUI is down: error 502 Bad Gateway

I guess LXC container is not allowed to bind to a network port?