Solved Roundcube could not connect to localhost:143: Unknown reason

marcus123

New Member

Thanks: 1
Messages: 9

#1
Hi, after setup roundcube, it can send email from installer page -> "Test SMTP config".

But I got this strange error on the installer page -> "Test IMAP config":

IMAP connect: NOT OK(Login failed for my-account-name from 192.168.123.188. Could not connect to localhost:143: Unknown reason)

Then I tried to login from roundcube login page, it shows "Connection to storage server failed.", while the roundcube errors log has below error:
IMAP Error: Login failed for myaccountname from 192.168.123.188. Could not connect to localhost:143: Unknown reason in /usr/local/www/roundcube/program/lib/Roundcube/rcube_imap.php on line 193 (POST /roundcube/?_task=login&_action=login)
However, use telnet to connect "localhost 143" from the same machine seems ok:
root@pc1:~ # telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
and I can also use telnet to connect the 143 port from another machine too. (and I can also successfully login and list the directories)

My roundcube config.inc.php:
Code:
$config['enable_installer'] = true;
$config['mime_types'] = '/usr/local/www/roundcube/config/mime.types';
$config['imap_vendor'] = 'dovecot';
$config['db_dsnw'] = 'mysql://roundcube:aa123aa@localhost/roundcube';
$config['default_host'] = 'localhost';
$config['support_url'] = '';
$config['des_key'] = 'somekeyhere';
I have checked the MariaDB database, it seems ok because it has some roundcube records in sessions table, it records all the login sessions I have tried before.

I have ever tried to set $config['password_charset'] = 'UTF-8' but the same problems still exists.

what is the problems? how can I fix it?

Roundcube 1.2.5
Dovecot 2.2.29
Postfix 3.1.4
MariaDB 10.1
PHP 7.1.5 (with imap)
Nginx 1.10
Freebsd 10.3

any suggestions is welcome, many thanks.
 
OP
OP
marcus123

marcus123

New Member

Thanks: 1
Messages: 9

#3
You need to login with username@domain.tld instead of just the username. At least that's what my own installation uses.
Thanks, I have tried it with username, username@domain, username@hostname.domain, username@ip, but all not work.

I have also tried to put the word "localhost", "localhost.localdomain" after the @ sign, but not work too...

Really strange that
  • I can use telnet to connect the 143 port from another machine, and successfully login with username only, and list the directories.
  • I have also tried to write a simple php program to call imap_open() and successfully login to localhost:143.
But just not work on roundcube...
 
OP
OP
marcus123

marcus123

New Member

Thanks: 1
Messages: 9

#4
As mentioned before, when I use telnet to connect "localhost 143", I see below:

root@pc1:~ # telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] Dovecot ready.

I feel doubt that... is it because it shows IDLE instead of STARTTLS ? if so, how can I set dovecot so it will show STARTTLS?
 

usdmatt

Daemon

Thanks: 476
Messages: 1,307

#5
IDLE is just one of the IMAP features being advertised by the server, that shouldn't cause any problem. Unless Roundcube is configured to require TLS, not having it enabled on the IMAP server shouldn't be an issue.

I'd suggest putting Roundcube in debug mode and seeing what the actual IMAP session looks like when it tries to connect & login.
 
OP
OP
marcus123

marcus123

New Member

Thanks: 1
Messages: 9

#6
Thanks all, I had finally solved it a month ago. I re-install everything again, and test each one, one by one, from Postfix, Dovecot, then Roundcube, just make sure each one work first then go to next one.

During the process, because I have installed openssl, I find that I finally need to re-install / upgrade openssl in order to make other software work, if anyone has the same case, make sure you have done below too:

echo 'DEFAULT_VERSIONS+=ssl=openssl' >> /etc/make.conf

After that, everything works... except RoundCube..., finally I find that it is because I had not notice the Software Requirement of RoundCube (oops!), I need to add some required php plugins too. (e.g. Socket support)
 
Top