Getting this error when trying to download a PDF of a submitted quotation. I assume it’s a pdf engine problem with wkhtmltopdf. Does wkhtmltopdf need to be installed/repaired? If so, is there documentation on how to do this? Thanks
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 120, in application
response = frappe.api.handle(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/api/__init__.py", line 52, in handle
data = endpoint(**arguments)
^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/api/v1.py", line 40, in handle_rpc_call
return frappe.handler.handle()
^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/handler.py", line 52, in handle
data = execute_cmd(cmd)
^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
return frappe.call(method, **frappe.form_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/__init__.py", line 1754, in call
return fn(*args, **newargs)
^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/utils/typing_validations.py", line 32, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "apps/erpnext/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py", line 514, in get_pdf
download_pdf(
File "apps/frappe/frappe/utils/typing_validations.py", line 32, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/utils/print_format.py", line 244, in download_pdf
pdf_file = frappe.get_print(
^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/utils/print_utils.py", line 92, in get_print
return get_pdf(html, options=pdf_options, output=output)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/utils/pdf.py", line 94, 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: ConnectionRefusedError
I think you can get this error when you don’t have the site name in your /etc/hosts file on the server.
What type of environment are you in (Docker, Debian, Ubuntu, etc)?
Are you using Multi-tenant/DNS like > bench config dns_multitenant on
Do you have a proxy server in front of your Frappe server?
Ubuntu on Docker, no multitenant and nginx for M365 email.
Exit with code 1 due to network error: ConnectionRefusedError means wkhtmltopdf cannot access the site URL to load print assets (CSS, images).
This usually happens when the site host_name is misconfigured, Nginx is not running, or the port does not match the active web server.
Please verify:
-
wkhtmltopdf 0.12.6 (patched Qt) is installed
-
host_name in site_config points to a reachable URL
-
Nginx is running and accessible from localhost
Once wkhtmltopdf can access /assets/* URLs, PDF generation works correctly.
I have been out of the office and will check this momentarily. Thanks
Good morning,
Wanted to follow up with you on this. So, a few days ago I was trying to get https to work which I eventually did. Requiring that I update hostname to my server’s name. Here is that post.
If I change that value back to frontend my https and ngix won’t work. Seems like I’m stuck in a catch 22.
Thoughts?
wkhtmltopdf 0.12.6 (with patched qt)
That is the version installed. I reconfirmed the ngix https is working and my hostname is correct.
I get the same error whether I use the https://myserver (which redirects to http://myserver:8080/ ) or direct to http://myserver:8080/
Stopping nginx has no effect, same error. Accessing site via http gives same error. Seems like something is hardcoded somewhere to look for “frontend” for outputting PDFs?
Other question, does outputting PDF’s use a different port?
For the sever error i was facing the same form my router one and there is detailed available on the internet.
Following instructions on #1589 when I try to run the command:
bench --site socketsite.localhost set-config host_name "http://myserver:8080"
No matter what I type in-place of socketsite.localhost I get Site does not exist.
I ran command from path: frappe@9cf02256c3f0:~/frappe-bench$:
bench --site all list-apps
which returns:
frappe 15.90.0 UNVERSIONED
erpnext 15.90.1 UNVERSIONED
I’ve tried frappe_docker-frontend-1, frappe_docker-backend-1, frappe.
If I use portainer I can see under volumes\frappe_docker_site
com.docker.compose.project frappe_docker
When I try the frappe_docker I get same error.
*Edit figured out it was frontend. But still get the original error. Is there something in nginx I need to mod as well?
You can either use vscode or the bash terminal to get into the common_site_config.json file and edit it manually but I think you are windows poweruser (like me) so try this from powershell: -
docker exec -it frappe_docker-backend-1 bench --site frontend set-config host_name “http://frontend:8080”
Hope it helps
I am a windows user but the server is on Ubuntu 
Just wanted to follow up. That fixed the issues. To be honest I was hesitant to do this because of using nginx and the ssl port redirections but appear to work now. Once again, thank you for your assistance!
1 Like