Gateway timeouts (error 504)

General discussion of Mantis.

Moderators: Contributor, Developer

Post Reply
Posts: 10
Joined: Jul 10, 2015 11:34 am

Gateway timeouts (error 504)

Post by doug_stevens » Jun 30, 2016 6:05 pm

I'm running the configuration shown below. About two weeks ago (~2016-06-16), we started encountering "504 Gateway Time-out" whenever we submit a modification on an issue. Could anyone recommend an approach to debugging this issue?

All of the changes for each modification appear to make it into the database, so I'm guessing the delay occurs after the database write. Additionally, the email associated with the change makes it, so the delay is probably also after the email is sent. I can't identify what change may have triggered this. My last change was to add the SourceBitBucket plugin (on 2016-05-06). There are four other subdomains on the same server, and none of those are showing timeouts.

There's nothing in the mantis log that indicates errors. I looked in core/constant_inc.php to see if there was a LOG_xxx for errors, but didn't find anything that looked relevant. /var/log/nginx/mantis.access.log looks normal, and /var/log/nginx/error.log shows the timeout errors (domain details obscured) ...
2016/06/30 22:35:26 [error] 1150#0: *4625 upstream timed out (110: Connection timed out) while reading response header from upstream, client:, server:, request: "GET /view_all_bug_page.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock", host: "", referrer: "
Mantis 1.2.19
Ubuntu 14.04.3 LTS
Chrome Version 51.0.2704.106 (64-bit)

Posts: 84
Joined: Dec 08, 2013 9:23 am
Location: Germany

Re: Gateway timeouts (error 504)

Post by aavagyan » Jul 05, 2016 5:31 pm


Might be to obvious, but did you try to uninstall plugins and re-try?
Did you try to 'inspect" page in Chrome's developer tool and check there 'Network' tab?
Mantis Statistics Plugin:

Posts: 10
Joined: Jul 10, 2015 11:34 am

Re: Gateway timeouts (error 504)

Post by doug_stevens » Jul 06, 2016 3:44 pm

I turned out to be a slowdown in sendmail. Once I disabled outgoing mail from mantis, the timeout disappeared.

Now all I need to do is debug sendmail ;-)

Site Admin
Posts: 6983
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: Gateway timeouts (error 504)

Post by atrol » Jul 06, 2016 4:27 pm

Check database table mantis_email_table
Are there a lot of entries in it?
Please use Search before posting and read the Manual

Posts: 5
Joined: Jul 25, 2017 8:46 am

Re: Gateway timeouts (error 504)

Post by thibaud » Jul 27, 2017 6:47 am

Dear all,

I am working in a company that uses mantis. When I arrive in this company it was already in place. The guy that put it in place left the company though.

I have exactly the same problem than described above and I cannot troubleshoot it. Please note that email notification has suddenly stopped recently also without reason.

If I make a change on a bug it works once but slower than before the problem occured. If I make a second change on a bug straight away after it goes to gateway timeout 504 and I cannot use mantis for 5 to 10 minutes.

I tried to put the parameter $g_enable_email_notification to OFF in config_inc.php but when I do so mantis web page does not load at all and it is written : possible whitespace/Error in configuration file - aborting output so far follows : string(3)"". Where do you copy the config_inc by the way ? is it in mantis directory or in mantis/core directory. I see it is at both places on my computer.

Below is my email config :

* MantisBT Email Settings *

$g_administrator_email = '';

$g_webmaster_email = '' ;

$g_from_email = '';


$g_from_name = 'Tokheim Mantis';

$g_return_path_email = '';

$g_enable_email_notification = ON;

$g_default_notify_flags = array('reporter' => ON,
'handler' => ON,
'monitor' => ON,
'bugnotes' => ON,
'explicit' => ON,
'threshold_min' => NOBODY,
'threshold_max' => NOBODY);

$g_notify_flags['new'] = array('bugnotes' => OFF,
'monitor' => OFF);

$g_notify_flags['monitor'] = array( 'reporter' => OFF,
'handler' => OFF,
'monitor' => OFF,
'bugnotes' => OFF,
'explicit' => ON,
'threshold_min' => NOBODY,
'threshold_max' => NOBODY);

$g_email_receive_own = OFF;

$g_validate_email = ON;

$g_check_mx_record = OFF;

$g_allow_blank_email = OFF;

$g_limit_email_domain = OFF;

$g_show_user_email_threshold = NOBODY;

$g_show_user_realname_threshold = NOBODY;

$g_mail_priority = 3;

$g_phpMailer_method = PHPMAILER_METHOD_SMTP;

$g_smtp_host = '';

$g_smtp_username = '';

$g_smtp_password = 'tokheim2014';

$g_smtp_connection_mode = 'tls';

$g_smtp_port = 587;

$g_email_send_using_cronjob = OFF;

$g_email_set_category = OFF;

$g_email_separator1 = str_pad('', 70, '=');

$g_email_separator2 = str_pad('', 70, '-');

$g_email_padding_length = 28;

Posts: 5
Joined: Jul 25, 2017 8:46 am

Re: Gateway timeouts (error 504)

Post by thibaud » Jul 28, 2017 5:03 am

I actually put CRON to ON and mantis works perfectly so it has to do with sending emails..

I think my problem is either the SMTP that not longer works either the mantis email table that is full and creates problem. I do not know how to see the entries of database table mantis_email_table. I have a SQL file which is 700 megabit in my mantis repertory..

How can I check this table and purge entries in this huge SQL file ?

Thank you

Post Reply