504 Gateway timeout when logging into RoundCube - Murgero?

Most accounts get a 504 Gateway Timeout when trying to login to roundcube.

Murgero, did you ever get the other guy helped out? That thread was closed with no solution.

nginx error log:

2018/01/19 11:57:41 [error] 1307#0: 20 upstream timed out (110: Connection time d out) while reading response header from upstream, client: ..., serv er: box..com, request: “POST /mail/?_task=login HTTP/1.1”, upst ream: “fastcgi://unix:/var/run/php/php7.0-fpm.sock”, host: “box.* .com”, referrer: "https://box.*.com/mail/?_task=mail&_mbox=Sent "


 To                         Action      From
 --                         ------      ----

[ 1] 22 ALLOW IN Anywhere
[ 2] 53 ALLOW IN Anywhere
[ 3] 25/tcp ALLOW IN Anywhere
[ 4] 587 ALLOW IN Anywhere
[ 5] 993 ALLOW IN Anywhere
[ 6] 995 ALLOW IN Anywhere
[ 7] 4190/tcp ALLOW IN Anywhere
[ 8] 80 ALLOW IN Anywhere
[ 9] 443 ALLOW IN Anywhere
[10] 22 (v6) ALLOW IN Anywhere (v6)
[11] 53 (v6) ALLOW IN Anywhere (v6)
[12] 25/tcp (v6) ALLOW IN Anywhere (v6)
[13] 587 (v6) ALLOW IN Anywhere (v6)
[14] 993 (v6) ALLOW IN Anywhere (v6)
[15] 995 (v6) ALLOW IN Anywhere (v6)
[16] 4190/tcp (v6) ALLOW IN Anywhere (v6)
[17] 80 (v6) ALLOW IN Anywhere (v6)
[18] 443 (v6) ALLOW IN Anywhere (v6)

The issue with the other guy was apache2 was installed along side nginx.


sudo apt remove apache2
sudo systemctl restart nginx

Also make sure php-fpm is running: sudo systemctl status php-fpm

If that does not work, let me know.
Also tag me next time with “@murgero

I appreciate your help sir.

Unfortunately, no dice on the apache or the service restarting. Still have the same issue.

user@box:~$ sudo apt remove apache2
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package ‘apache2’ is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
user@box:~$ sudo systemctl restart nginx
sudo: systemctl: command not found
user@box:~$ sudo /etc/init.d/nginx restart

  • Restarting nginx nginx [ OK ]
    ian@box:~$ sudo /etc/init.d/php7.0-fpm status
    php7.0-fpm start/running, process 34571

Nothing in syslog or nginx logs? More than what you have shown?

It’s really strange. Some accounts can login just fine. Others get the timeout.

Nothing useful in syslog, just munin updates.

Login attempt:


... - - [22/Jan/2018:10:23:54 -0600] “GET /mail/skins/larry/images/ajaxloader.gif?v=c252.1434 HTTP/1.1” 200 1434 “” “Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36”


2018/01/22 10:24:54 [error] 61450#0: 74 upstream timed out (110: Connection timed out) while reading response header from upstream, client:, server: box..com, request: “POST /mail/?_task=login HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php/php7.0-fpm.sock”, host: “”, referrer: “

What version of MIAB? Also would you mind creating an account for me on your box and passing me the credentials in a PM? I would like to test with you on this.

I’d PM, but my account is too new. It doesn’t give me the option to.

Version v0.26

This problem seemed to arise after running the upgrade script.

Shoot me an email: thatguy at just1fix dot com

New info. It is some form of roundcube issue, I was able to connect to the account with thunderbird.

Ah version 0.26 has a lot of issues (which is why I am still on 0.25)

I can still look into this for you, or you can wait for 0.26b (or 0.27) which should be dropping soon to fix installation bugs.

I was unaware that this release was buggy. I’ll just install thunderbird on some of the client computers and tell them to stay away from roundcube for now.

Hey man, thank you so much for all of your help.

If you need anything 3d printed or a miniature painted, let me know. =)

Thanks! One work around, which I highly recommend, is using rainloop in NextCloud.

Enable admin account in next cloud, then install the rainloop app from the app center in nextcloud, configure to use nextclouds session for login and BOOM. Cloud and mail in /cloud. works well.

Also have the user login to nextcloud, then try roundcube again.

murgero, sorry I’ve been away for a bit (work), and just upgraded to v0.26. Is there a list of the bugs for this version somewhere? The upgrade went pretty smooth, but wanted to see if there was a list of the bugs so I can check for them in my environment.

Right now, from what I can tell, bugs include:

  • Unable to login to roundcube
  • Unable to upgrade MIAB properly in some cases (fails on admin email)
  • Unable to login to NextCloud
  • Apache2 is being removed, but it also removes some PHP modules, which could in theory break websites.

good morning

I report the same problem on the v0.23a version that we have in production.

This is a part of the nginx log:

2018/03/16 18:38:42 [error] 1377#0: *81340 upstream timed out (110: Connection timed out) while reading response header from upstream, client:, server: mail.mailserver.xxx, request: “POST /mail/?_task=login HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php5-fpm.sock”, host: “mail.mailserver.xxx”, referrer: “https://mail.mailserver.xxx/mail/?_task=mail&_mbox=INBOX
2018/03/16 18:39:27 [error] 1379#0: *81450 upstream timed out (110: Connection timed out) while reading response header from upstream, client:, server: box.mailserver.xxx, request: “POST /mail/?_task=login HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php5-fpm.sock”, host: “box.mailserver.xxx”, referrer: “https://box.mailserver.xxx/mail/

I suppose the problem is the communication between php-fpm and nginx

We have already tried the rainloop alternative on Nextcloud, but there are problems with php-fpm.

What can we do?

We have updated to version 0.26c
Now works.

I also recommend installing the rainloop app on Nextcloud.

Thanks for the support

Forget it

Same problem

Nginx continues to give problems, does it make sense to keep it?

It is a serious problem

Anyway, I have increased the resources of the system and now it seems to work …

let’s hope…

Do you have apache installed as well?

No, Apache is not installed.
I tried to increase the verbosity of PHP but the log file stays empty (only startup and shutdown of the service).
Any ideas?

For roundcube and admin panel i think logs are stored in syslog.

Thanks for the reply.

I don’t celebrate too early

But now we have increased the resources of the VPS machine and added a swapfiles. And until now he has not given any problems.

Let’s see how it behaves.