1 (edited by minikN 2020-08-23 06:17:31)

Topic: Can't access iredadmin: 502 Bad Gateway

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.3.1
- Deployed with iRedMail Easy or the downloadable installer? Installer
- Linux/BSD distribution name and version: Ubuntu 20.04
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- 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.
====

Hello. I've setup iRedMail using

bash iRedMail.sh

. After the installation is done. I can access roundcube, but not iredadmin: 502 Bad Gateway. A look into the nginx logs reveals:

2020/08/23 00:01:44 [error] 590#590: *138 connect() failed (111: Connection refused) while connecting to upstream, client: 94.134.179.125, server: _, request: "GET /iredadmin HTTP/1.1", upstream: "uwsgi://127.0.0.1:7791", host: "mail.domain.xyz"

(I changed the domain).

systemctl status uwgsi
● uwsgi.service - LSB: Start/stop uWSGI server instance(s)
     Loaded: loaded (/etc/init.d/uwsgi; generated)
     Active: active (exited) since Sun 2020-08-23 00:03:05 CEST; 13min ago
       Docs: man:systemd-sysv-generator(8)
    Process: 2952 ExecStart=/etc/init.d/uwsgi start (code=exited, status=0/SUCCESS)

Aug 23 00:03:05 mail systemd[1]: Starting LSB: Start/stop uWSGI server instance(s)...
Aug 23 00:03:05 mail uwsgi[2952]:  * Starting app server(s) uwsgi
Aug 23 00:03:05 mail uwsgi[2952]:    ...done.
Aug 23 00:03:05 mail systemd[1]: Started LSB: Start/stop uWSGI server instance(s).

I've tried to solve this by myself, however I was unsuccesful.

I'd appreciate any assistance.

----

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

2

Re: Can't access iredadmin: 502 Bad Gateway

Please access iRedAdmin and do checks below immediately:

- What's the output of command "service iredadmin status"?
- What's the last 20 lines of /var/log/syslog?

3 (edited by minikN 2020-08-23 15:43:09)

Re: Can't access iredadmin: 502 Bad Gateway

ZhangHuangbin wrote:

Please access iRedAdmin and do checks below immediately:

- What's the output of command "service iredadmin status"?
- What's the last 20 lines of /var/log/syslog?

Hello:

root@mail:~# service iredadmin status
● iredadmin.service - iRedAdmin daemon service
     Loaded: loaded (/lib/systemd/system/iredadmin.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2020-08-22 23:55:22 CEST; 9h ago
    Process: 530 ExecStartPre=/bin/mkdir -p /var/run/iredadmin (code=exited, status=0/SUCCESS)
    Process: 580 ExecStartPre=/bin/chown iredadmin:iredadmin /var/run/iredadmin (code=exited, status=0/SUCCESS)
    Process: 596 ExecStartPre=/bin/chmod 0755 /var/run/iredadmin (code=exited, status=0/SUCCESS)
    Process: 601 ExecStart=/usr/local/bin/uwsgi --ini /opt/www/iredadmin/rc_scripts/uwsgi/debian.ini --pidfile /var/run/iredadmin/iredadmin.pid (code=exited, status=203/EXEC)
    Process: 613 ExecStopPost=/bin/rm -rf /var/run/iredadmin (code=exited, status=0/SUCCESS)
   Main PID: 601 (code=exited, status=203/EXEC)

Aug 22 23:55:21 mail systemd[1]: Starting iRedAdmin daemon service...
Aug 22 23:55:22 mail systemd[601]: iredadmin.service: Failed to execute command: No such file or directory
Aug 22 23:55:22 mail systemd[601]: iredadmin.service: Failed at step EXEC spawning /usr/local/bin/uwsgi: No such file or directory
Aug 22 23:55:22 mail systemd[1]: Started iRedAdmin daemon service.
Aug 22 23:55:22 mail systemd[1]: iredadmin.service: Main process exited, code=exited, status=203/EXEC
Aug 22 23:55:22 mail systemd[1]: iredadmin.service: Failed with result 'exit-code'.
root@mail:~#


Aug 22 23:55:21 mail systemd[1]: Starting iRedAdmin daemon service...
Aug 22 23:55:22 mail systemd[601]: iredadmin.service: Failed to execute command: No such file or directory
Aug 22 23:55:22 mail systemd[601]: iredadmin.service: Failed at step EXEC spawning /usr/local/bin/uwsgi: No such file or directory
Aug 22 23:55:22 mail systemd[1]: Started iRedAdmin daemon service.
Aug 22 23:55:22 mail systemd[1]: iredadmin.service: Main process exited, code=exited, status=203/EXEC
Aug 22 23:55:22 mail systemd[1]: iredadmin.service: Failed with result 'exit-code'.

The last 20 lines or so of

/var/log/syslog
Aug 23 09:33:02 mail systemd[1]: Created slice User Slice of UID 0.
Aug 23 09:33:02 mail systemd[1]: Starting User Runtime Directory /run/user/0...
Aug 23 09:33:02 mail systemd[1]: Finished User Runtime Directory /run/user/0.
Aug 23 09:33:02 mail systemd[1]: Starting User Manager for UID 0...
Aug 23 09:33:02 mail systemd[17637]: Reached target Paths.
Aug 23 09:33:02 mail systemd[17637]: Reached target Timers.
Aug 23 09:33:02 mail systemd[17637]: Starting D-Bus User Message Bus Socket.
Aug 23 09:33:02 mail systemd[17637]: Listening on GnuPG network certificate management daemon.
Aug 23 09:33:02 mail systemd[17637]: Listening on GnuPG cryptographic agent and passphrase cache (access for web browsers).
Aug 23 09:33:02 mail systemd[17637]: Listening on GnuPG cryptographic agent and passphrase cache (restricted).
Aug 23 09:33:02 mail systemd[17637]: Listening on GnuPG cryptographic agent (ssh-agent emulation).
Aug 23 09:33:02 mail systemd[17637]: Listening on GnuPG cryptographic agent and passphrase cache.
Aug 23 09:33:02 mail systemd[17637]: Listening on debconf communication socket.
Aug 23 09:33:02 mail systemd[17637]: Listening on D-Bus User Message Bus Socket.
Aug 23 09:33:02 mail systemd[17637]: Reached target Sockets.
Aug 23 09:33:02 mail systemd[17637]: Reached target Basic System.
Aug 23 09:33:02 mail systemd[1]: Started User Manager for UID 0.
Aug 23 09:33:02 mail systemd[1]: Started Session 675 of user root.
Aug 23 09:33:02 mail systemd[17637]: Reached target Main User Target.
Aug 23 09:33:02 mail systemd[17637]: Startup finished in 107ms.
Aug 23 09:34:01 mail CRON[17701]: (root) CMD (/bin/bash /usr/local/bin/fail2ban_banned_db unban_db)

It can't seem to find the uwsgi executable. The path

/usr/local/bin/uwsgi

is actually wrong. It's

root@mail:~# which uwsgi
/usr/bin/uwsgi

Thanks in advance.

4

Re: Can't access iredadmin: 502 Bad Gateway

/usr/local/bin/uwsgi is installed by Python (v2) pip package. Please fix it with command:

pip2 install uwsgi
service iredadmin restart

5 (edited by minikN 2020-08-25 19:20:52)

Re: Can't access iredadmin: 502 Bad Gateway

Okay I did that.

service iredadmin status

now shows:

● iredadmin.service - iRedAdmin daemon service
     Loaded: loaded (/lib/systemd/system/iredadmin.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2020-08-25 13:11:54 CEST; 6min ago
    Process: 535 ExecStartPre=/bin/mkdir -p /var/run/iredadmin (code=exited, status=0/SUCCESS)
    Process: 586 ExecStartPre=/bin/chown iredadmin:iredadmin /var/run/iredadmin (code=exited, status=0/SUCCESS)
    Process: 605 ExecStartPre=/bin/chmod 0755 /var/run/iredadmin (code=exited, status=0/SUCCESS)
   Main PID: 612 (uwsgi)
      Tasks: 6 (limit: 2286)
     Memory: 24.7M
     CGroup: /system.slice/iredadmin.service
             ├─612 /usr/local/bin/uwsgi --ini /opt/www/iredadmin/rc_scripts/uwsgi/debian.ini --pidfile /var/run/iredadmin/iredadmin.pid
             ├─784 /usr/local/bin/uwsgi --ini /opt/www/iredadmin/rc_scripts/uwsgi/debian.ini --pidfile /var/run/iredadmin/iredadmin.pid
             ├─785 /usr/local/bin/uwsgi --ini /opt/www/iredadmin/rc_scripts/uwsgi/debian.ini --pidfile /var/run/iredadmin/iredadmin.pid
             ├─786 /usr/local/bin/uwsgi --ini /opt/www/iredadmin/rc_scripts/uwsgi/debian.ini --pidfile /var/run/iredadmin/iredadmin.pid
             ├─787 /usr/local/bin/uwsgi --ini /opt/www/iredadmin/rc_scripts/uwsgi/debian.ini --pidfile /var/run/iredadmin/iredadmin.pid
             └─788 /usr/local/bin/uwsgi --ini /opt/www/iredadmin/rc_scripts/uwsgi/debian.ini --pidfile /var/run/iredadmin/iredadmin.pid

Aug 25 13:17:09 mail uwsgi[612]:   File "/usr/local/lib/python2.7/dist-packages/web/db.py", line 1299, in import_driver
Aug 25 13:17:09 mail uwsgi[612]:
Aug 25 13:17:09 mail uwsgi[612]: raise ImportError("Unable to import " + " or ".join(drivers))
Aug 25 13:17:09 mail uwsgi[612]: ImportError
Aug 25 13:17:09 mail uwsgi[612]: :
Aug 25 13:17:09 mail uwsgi[612]: Unable to import MySQLdb or pymysql or mysql.connector
Aug 25 13:17:09 mail uwsgi[612]:
Aug 25 13:17:09 mail uwsgi[612]: unable to load app 0 (mountpoint='mail.domain.com|/iredadmin') (callable not found or import error)
Aug 25 13:17:09 mail uwsgi[612]: --- no python application found, check your startup logs for errors ---
Aug 25 13:17:09 mail uwsgi[612]: mail.domain.com [pid: 788|app: -1|req: -1/1] 2001:16b8:2e6f:cd00:5d0e:ee0a:94c1:b590 () {56 vars in 10>

And I get an Internal Server Error when visiting the URL.

6

Re: Can't access iredadmin: 502 Bad Gateway

I seem to have fixed it by running:

pip2 install py-mysql

7

Re: Can't access iredadmin: 502 Bad Gateway

It should be:

pip2 install pymysql