Topic: 'DATABASE ERROR: CONNECTION FAILED!' in a FreeBSD Jail
======== Required information ====
- iRedMail version (check /etc/iredmail-release): iRedmail-0.9.6
- Linux/BSD distribution name and version: FreeBSD 11.0-RELEASE-p8
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- Related log if you're reporting an issue: N/A
====
I have tested two instances of iRedmail: Both FreeBSD, but one running on the base system and one running in a jail. The one not running in a jail works great but the one in the jail is unable to connect to the database when I hit https://mx.example.com/mail/
DATABASE ERROR: CONNECTION FAILED!
Unable to connect to the database!
Please contact your server-administrator.
When I am inside the jail and I try to connect to the database with a command such as 'mysql -h 127.0.0.1 -u root -p' I am told that root@localhost is not allowed to connect. I noticed that in the jail that nothing is actually listening on 127.0.01 because jails don't have loopback devices. As you can see in the jail using 'sockstat -4' to show what ports things are listening on
vscan perl 37580 6 tcp4 192.168.0.62:10024 *:*
vscan perl 37580 7 tcp4 192.168.0.62:10026 *:*
vscan perl 37580 8 tcp4 192.168.0.62:9998 *:*
vscan perl 37578 6 tcp4 192.168.0.62:10024 *:*
vscan perl 37578 7 tcp4 192.168.0.62:10026 *:*
vscan perl 37578 8 tcp4 192.168.0.62:9998 *:*
vscan perl 37577 6 tcp4 192.168.0.62:10024 *:*
vscan perl 37577 7 tcp4 192.168.0.62:10026 *:*
vscan perl 37577 8 tcp4 192.168.0.62:9998 *:*
vscan perl 37576 6 tcp4 192.168.0.62:10024 *:*
vscan perl 37576 7 tcp4 192.168.0.62:10026 *:*
vscan perl 37576 8 tcp4 192.168.0.62:9998 *:*
vscan perl 37575 6 tcp4 192.168.0.62:10024 *:*
vscan perl 37575 7 tcp4 192.168.0.62:10026 *:*
vscan perl 37575 8 tcp4 192.168.0.62:9998 *:*
iredapd python2.7 19054 3 tcp4 192.168.0.62:7777 *:*
nobody memcached 19043 16 tcp4 192.168.0.62:11211 *:*
nobody memcached 19043 17 udp4 192.168.0.62:11211 *:*
nobody memcached 19043 18 udp4 192.168.0.62:11211 *:*
nobody memcached 19043 19 udp4 192.168.0.62:11211 *:*
nobody memcached 19043 20 udp4 192.168.0.62:11211 *:*
www nginx 19034 3 tcp4 192.168.0.62:443 192.168.0.13:53513
www nginx 19034 6 tcp4 192.168.0.62:80 *:*
www nginx 19034 7 tcp4 192.168.0.62:443 *:*
www nginx 19034 10 tcp4 192.168.0.62:443 192.168.0.13:53519
www nginx 19034 11 tcp4 192.168.0.62:443 192.168.0.13:53520
www nginx 19034 12 tcp4 192.168.0.62:443 192.168.0.13:53521
root nginx 19033 6 tcp4 192.168.0.62:80 *:*
root nginx 19033 7 tcp4 192.168.0.62:443 *:*
root master 19013 13 tcp4 192.168.0.62:25 *:*
root master 19013 97 tcp4 192.168.0.62:587 *:*
root master 19013 106 tcp4 192.168.0.62:10025 *:*
vmail lmtp 18920 9 tcp4 192.168.0.62:24 *:*
vmail lmtp 18919 9 tcp4 192.168.0.62:24 *:*
vmail lmtp 18918 9 tcp4 192.168.0.62:24 *:*
vmail lmtp 18917 9 tcp4 192.168.0.62:24 *:*
vmail lmtp 18913 9 tcp4 192.168.0.62:24 *:*
root dovecot 18910 15 tcp4 192.168.0.62:4190 *:*
root dovecot 18910 26 tcp4 192.168.0.62:110 *:*
root dovecot 18910 27 tcp4 192.168.0.62:995 *:*
root dovecot 18910 31 tcp4 192.168.0.62:24 *:*
root dovecot 18910 41 tcp4 192.168.0.62:143 *:*
root dovecot 18910 42 tcp4 192.168.0.62:993 *:*
vscan perl 17206 6 tcp4 192.168.0.62:10024 *:*
vscan perl 17206 7 tcp4 192.168.0.62:10026 *:*
vscan perl 17206 8 tcp4 192.168.0.62:9998 *:*
vscan perl 17202 6 tcp4 192.168.0.62:10024 *:*
vscan perl 17202 7 tcp4 192.168.0.62:10026 *:*
vscan perl 17202 8 tcp4 192.168.0.62:9998 *:*
vscan perl 17201 6 tcp4 192.168.0.62:10024 *:*
vscan perl 17201 7 tcp4 192.168.0.62:10026 *:*
vscan perl 17201 8 tcp4 192.168.0.62:9998 *:*
vscan perl 17195 6 tcp4 192.168.0.62:10024 *:*
vscan perl 17195 7 tcp4 192.168.0.62:10026 *:*
vscan perl 17195 8 tcp4 192.168.0.62:9998 *:*
mysql mysqld 17189 31 tcp4 192.168.0.62:3306 *:*
sogod sogod 16432 6 tcp4 192.168.0.62:20000 *:*
sogod sogod 16431 6 tcp4 192.168.0.62:20000 *:*
sogod sogod 16430 6 tcp4 192.168.0.62:20000 *:*
sogod sogod 16429 6 tcp4 192.168.0.62:20000 *:*
sogod sogod 16428 6 tcp4 192.168.0.62:20000 *:*
sogod sogod 16427 6 tcp4 192.168.0.62:20000 *:*
sogod sogod 16420 6 tcp4 192.168.0.62:20000 *:*
sogod sogod 16417 6 tcp4 192.168.0.62:20000 *:*
sogod sogod 16415 6 tcp4 192.168.0.62:20000 *:*
sogod sogod 16409 6 tcp4 192.168.0.62:20000 *:*
sogod sogod 15828 6 tcp4 192.168.0.62:20000 *:*
Are roundcube and other pieces of iRedmail trying to connect to MySQL on 127.0.0.1? Is there a workaround for this when running in it a jail? Perhaps modifying the script to tell it to connect on the jails IP such as 192.168.0.62?
----
Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.