Nextcloud Mail & gmail: Request failed with status code 500

When trying to connect a gmail-account to mail, it gives the following error:

Request failed with status code 500

The credentials I input are correct. Also I’ve enabled the less secure apps-option in Gmail. IMAP is also enabled.

I’ve been searching for a solution on the forums a while now, but can’t find any. In my apache-logs I see:

|2020-04-17 13:40:43|Error|IP|500|POST /index.php/apps/mail/api/accounts HTTP/1.0||Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0|1.67 K|SSL/TLS-toegang tot Apache|
|2020-04-17 13:41:28|Warning|IP||mod_fcgid: read data timeout in 45 seconds||||Foutmelding van Apache|
|2020-04-17 13:41:28|Error|IP||End of script output before headers: index.php||||Foutmelding van Apache|

How can I find the problem? I already tried to add debug to config.php, but that doens’t tell anything. Also, in the log of nextcloud.log there’s no extra information.

Many thanks in advance!

Have you checked nextcloud.log? It definitely should log the reason for this error. Alternatively check data/horde_imap.log and data/horde_smtp.log after enabling debug mode to see if you can find an error there.

Thx for your quick response! Solved it:

  • I checked nextcloud.log, but it didn’t tell anything;
  • I didn’t check data/horde_imap.log, but thanks to your response I found out it was some sort of authentication failure. Even though my e-mailadres and password were correct and gmail allowed insecure apps.


  1. Enable two-factor authentication:

  2. Enable app-passwords:

Use the app-password to login, this fixed my problem :slight_smile: