JobTimeoutException: Job exceeded maximum timeout value (300 seconds)

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/”, line 268, in receive
communication = self.insert_communication(msg, args=args)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/”, line 345, in insert_communication
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 231, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 267, in _save
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 406, in _validate
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 638, in _sanitize_content
sanitized_value = sanitize_html(value, linkify=df.fieldtype==‘Text Editor’)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/”, line 24, in sanitize_html
escaped_html = bleach.clean(html, tags=tags, attributes=attributes, styles=styles, strip_comments=strip_comments)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/bleach/”, line 77, in clean
return cleaner.clean(text)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/bleach/”, line 133, in clean
dom = self.parser.parseFragment(text)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/html5lib/”, line 253, in parseFragment
self._parse(stream, True, *args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/html5lib/”, line 89, in _parse
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/html5lib/”, line 193, in mainLoop
new_token = phase.processCharacters(new_token)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/html5lib/”, line 1602, in processCharacters
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/html5lib/treebuilders/”, line 326, in insertText
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/html5lib/treebuilders/”, line 111, in insertText
self._element.text += data
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/rq/”, line 51, in handle_death_penalty
‘value ({0} seconds)’.format(self._timeout))
JobTimeoutException: Job exceeded maximum timeout value (300 seconds)

I think you need to provide a few more details for folk to really help you. Ie version numbers, what you were doing when error occured etc etc

As far as it stands all it says is that erpnext waited 5 mins before giving up downloading an email. Perhaps your mail server was slow or down at the same of it had a very large attachment ?

Can the error be replicated? What mail provider are you using? How are you connecting to it in the cloud or erpnext on a local machine?

I am using office365 mail server my server is connected to the internet with dedicated fiber and enough bandwidth to run an entire block. my ERPNEXT box is running 4G of RAM with 4 vCPU am running version 8 of ERPNEXT. Am going to check to see if the attachment is 2 large and try and reproduce the error by sending email to in incoming email address setup in ERPNEXT.

Did you manage to resolve this? I ask as I got a similar problem a couple of days back too with a 300s timeout.

No…still an issess.

The traceback indicates a problem ‘saniitizing’ the html content of a particular email -

You may have to identify and delete that email from the server for imap to resume downloads?

1 Like

Yup I guess the html5 parser could not handle ‘bad’ input and became hung.

What a nuisance especially if the email was spam :frowning:

I’m getting similar error while sending out emails. Any advice on how to proceed with troubleshooting it?

A good strategy or questions worth asking to start with are

Have you searched the forum and what have you tried or not tried?

1 Like

I haven’t had any similar issues since April fortunately.

I suspect that the timeout is related to your mail server being busy or a large email to download or your ERPNext instance is busy or a combination of the above.

1 Like

I have same issue sometime, when email provider busy.

It will pull on next schedule, don’t worry.

Hope this helps.

1 Like

Thanks Clarke, Yea I have tried searching the forum and this post was the closest to the issue I was facing.

I managed to partially resolve the issue by setting a default sent email account. Once that was set then the Admin could send the emails (notification emails were working fine). I think the user specific emails are not properly configured and I’ll check there was some mistake in setting it.


1 Like

Did you install erpnext from scratch or did use a prepaid image from google cloud or other sources?

HI Jermaine, I installed it from scratch.

Yea the individual ones are still not working.

I’m also getting this error for a custom background job. Is there a setting where we can extend the limit to more than 5 min?

Somewhere I read that you can do that in site_config.json. Let me see if I can find it.

With gmail my experience be advised: Less than 15 minutes between polls to check and pull mail, and their service will ignore your request for some interval

frappe@erpnext:~/frappe-bench$ bench set-config scheduler_interval 900

1 Like

I couldn’t find this setting anywhere. My payroll processing is still timing out. here is my trace -

Site: site1.local
Form Dict: {
 "cmd": "runserverobj",
 "docs": "{\"creation\":\"2016-06-16 11:34:07.761273\",\"doctype\":\"Process Payroll\",\"owner\":\"Administrator\",\"modified_by\":\"Administrator\",\"idx\":\"0\",\"docstatus\":0,\"name\":\"Process Payroll\",\"modified\":\"2016-06-16 11:34:07.761273\",\"salary_slip_based_on_timesheet\":0,\"__last_sync_on\":\"2017-09-04T04:13:50.592Z\",\"posting_date\":\"2017-09-04\",\"start_date\":\"2017-08-01\",\"end_date\":\"2017-08-31\",\"payroll_frequency\":\"Monthly\",\"company\":\"AH Private Limited\",\"__unsaved\":1,\"cost_center\":\"Main - AHPL\"}",
 "method": "create_salary_slips"
Request Error
Traceback (most recent call last):
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/", line 55, in application
    response = frappe.handler.handle()
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/", line 21, in handle
    data = execute_cmd(cmd)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/", line 52, in execute_cmd
    return, **frappe.form_dict)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/", line 907, in call
    return fn(*args, **newargs)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/", line 80, in runserverobj
    frappe.desk.form.run_method.runserverobj(method, docs=docs, dt=dt, dn=dn, arg=arg, args=args)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/", line 22, in runserverobj
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/", line 517, in check_if_latest
    where doctype=%s and field='modified' for update''', self.doctype)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/", line 138, in sql
    self._cursor.execute(query, values)
  File "/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/", line 250, in execute
    self.errorhandler(self, exc, value)
  File "/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/", line 42, in defaulterrorhandler
    raise errorvalue
OperationalError: (1205, 'Lock wait timeout exceeded; try restarting transaction')```

Any help?

This might help you troubleshoot your issue - your timeout relates to a database update that is a separate context from a JobTimeException

frappe@erpnext:~/frappe-bench$ mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5263
Server version: 10.0.29-MariaDB-1~trusty binary distribution

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> show variables like 'innodb_lock_wait_timeout';
| Variable_name            | Value |
| innodb_lock_wait_timeout | 50    |
1 row in set (0.11 sec)