PDF generation for Sales Invoice print format results in timeout error

Hi
I am getting the following error when I click on the PDF button for Sales Invoice print format.
Server configuration has 1GB RAM and 4GB of Virtual Swap, is it a memory issue or something else?

Traceback (most recent call last):
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/app.py”, line 61, in application
response = frappe.api.handle()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/api.py”, line 54, in handle
return frappe.handler.handle()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/handler.py”, line 42, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 907, in call
return fn(*args, **newargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/print_format.py”, line 48, in download_pdf
frappe.local.response.filecontent = get_pdf(html)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/pdf.py”, line 17, in get_pdf
pdfkit.from_string(html, fname, options=options or {})
File “/home/ubuntu/frappe-bench/env/src/pdfkit/pdfkit/api.py”, line 68, in from_string
return r.to_pdf(output_path)
File “/home/ubuntu/frappe-bench/env/src/pdfkit/pdfkit/pdfkit.py”, line 140, in to_pdf
raise IOError(‘wkhtmltopdf reported an error:\n’ + stderr.decode(‘utf-8’))
IOError: wkhtmltopdf reported an error:
Exit with code 1 due to network error: TimeoutError

Is this error only on Sales Invoice or on all doc types like Quotation, Purchase Order etc ?

I am facing the same issue in Quotation and Purchase order as well, it takes about 2-3 mins and times out.

If you don’t have any changes or customizations then probably your memory swap needs to be set up correctly or you many need min of 2 GB RAM.

Also, ensure wkhtmltopdf component was installed successfully during ERPNext installation.

Here are my swap settings:
ubuntu@ip-172-31-18-134:~$ free -m
total used free shared buff/cache available
Mem: 990 411 328 2 251 397
Swap: 4095 256 3839

I thought that a 4 GB swap was good enough and I had used the standard install.py script for prod mode and wkhtmltopdf was installed along with other pre-requisites automatically. What am I missing?

Maybe check your timeout set in nginx.

Increased timeout from 120 to 1200 in nginx.conf, but it’s still the same. I hope you are referring to this:
proxy_read_timeout 1200;