DNS ----> Try running “curl -vI http://web.erp.domain”. Once the domain responds, wkhtmltopdf will work without any issues.
Of course, you need to make sure it’s accessible.
In my case, using a proxy, I edited the /etc/hosts file and, instead of using the local server’s IP, I used the proxy’s IP. That’s it—no other changes needed.
I’m unable to send emails using my Gmail account, and I also can’t print invoices. I have already set the host_name to my site name, which is proxied through Nginx Proxy Manager, but the issue persists.
Has anyone found a solution or have any suggestions on what else I might try? Thanks in advance for your help!
Confirm if the site location is accessible from within workers and gunicorn containers. If the process cannot connect to host_name it’ll not be able to generate pdf.
Access from browser is different, that you already have.
Use extra_hosts or figure out way to resolve images from containers.
Thank you for your prompt response! I would appreciate your assistance, and I’ll gladly treat you to lunch for your help.
I’m currently running Docker with WSL, Portainer, Nginx Proxy Manager, and a Cloudflare tunnel in a container. The frontend is proxied through Nginx and is accessible via the internet through the Cloudflare tunnel. All containers have external site access, so I don’t need to add extra_hosts directives (which I believe have been deprecated). They are utilizing the Docker bridge network. For example, I’m able to successfully run:
curl https://test.menteware.com
Here’s the stack configuration I have set up in Portainer:
And this is error from Frappe when sending the queue email with the document attached:
Traceback (most recent call last):
File "apps/frappe/frappe/utils/pdf.py", line 90, in get_pdf
filedata = pdfkit.from_string(html, options=options or {}, verbose=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "env/lib/python3.11/site-packages/pdfkit/api.py", line 75, in from_string
return r.to_pdf(output_path)
^^^^^^^^^^^^^^^^^^^^^
File "env/lib/python3.11/site-packages/pdfkit/pdfkit.py", line 201, in to_pdf
self.handle_error(exit_code, stderr)
File "env/lib/python3.11/site-packages/pdfkit/pdfkit.py", line 155, in handle_error
raise IOError('wkhtmltopdf reported an error:\n' + stderr)
OSError: wkhtmltopdf reported an error:
Exit with code 1 due to network error: ContentOperationNotPermittedError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 167, in send
message = ctx.build_message(recipient.recipient)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 315, in build_message
message = self.include_attachments(message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 392, in include_attachments
print_format_file = frappe.attach_print(**attachment)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/__init__.py", line 2232, in attach_print
else get_print(doctype, name, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/__init__.py", line 2191, in get_print
return get_pdf(html, options=pdf_options, output=output) if as_pdf else html
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/utils/pdf.py", line 98, in get_pdf
frappe.throw(_("PDF generation failed because of broken image links"))
File "apps/frappe/frappe/__init__.py", line 652, in throw
msgprint(
File "apps/frappe/frappe/__init__.py", line 617, in msgprint
_raise_exception()
File "apps/frappe/frappe/__init__.py", line 568, in _raise_exception
raise exc
frappe.exceptions.ValidationError: PDF generation failed because of broken image links
Could you please clarify where I should add the extra_hosts directive? All containers can access external sites and return the expected HTML when I run:
curl https://test.menteware.com
But I’m unsure why I might need extra_hosts in this scenario. Any guidance would be greatly appreciated!
Then image issue need more info. You can exec into the container and do bench --site site.name.com console then try to execute the python functions that are causing problems. Tweak code in console to understand why it triggers error.