Roundcube SMTP Error (): Connection to server failed

I’m using brevo for an smtp relay. This is the errors.log

[05-Apr-2026 12:05:05 UTC] PHP Warning: stream_socket_client(): Unable to connect to localhost:587 (Connection refused) in /var/lib/roundcube/vendor/pear/n>
[05-Apr-2026 12:05:05 +0000]: PHP Error: Connection refused (POST /?_task=mail&_unlock=loading1775390705758&_framed=1&_action=send)
[05-Apr-2026 12:05:05 +0000]: PHP Error: Failed to connect socket: Connection refused (POST /?_task=mail&_unlock=loading1775390705758&framed=1&>
[05-Apr-2026 12:05:05 +0000]: SMTP Error: Connection failed: (Code: -1) in /var/lib/roundcube/program/lib/Roundcube/rcube.php on line 1799 (POST>

Thanks and more power!

I was able to fix it by changing the /etc/roundcube/config.inc.php

from this:

$config[“smtp_host”] = “localhost:587”;

to

$config[‘smtp_server’] = ‘tls://127.0.0.1’;
$config[‘smtp_port’] = 587;
$config[‘smtp_user’] = ‘%u’;
$config[‘smtp_pass’] = ‘%p’;

seems like it’s using an old config ,for whatever reason i have no idea.

Hi,

localhost:587 should work fine. I suppose the issue is that your localhost is resolving to IPv6 ::1 and that’s the reason it can’t connect to Exim.

You could check it with telnet (if you don’t have telnet, then apt install telnet):

telnet localhost 587

connection refused if I try to telnet to 587

But I want to see whether it tries to connect to ::1

gavin@hostingcp:~$ telnet localhost 587
Trying ::1…
telnet: Unable to connect to remote host: Connection refused

Ok, to fix it you can edit the file /etc/hosts and remove localhost from ::1 entry.

GNU nano 7.2 /etc/hosts *
::1 ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

removed. thank you very much, really appreciate it

2 Likes