OSError: wkhtmltopdf reported an error: Exit with code 1 due to network error: SslHandshakeFailedError

When i clicked pdf on print page


this error show up after click pdf

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 58, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 45, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1597, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/utils/print_format.py", line 129, in download_pdf
    frappe.local.response.filecontent = get_pdf(html)
  File "apps/frappe/frappe/utils/pdf.py", line 38, in get_pdf
    filedata = pdfkit.from_string(html, options=options or {}, verbose=True)
  File "env/lib/python3.10/site-packages/pdfkit/api.py", line 75, in from_string
    return r.to_pdf(output_path)
  File "env/lib/python3.10/site-packages/pdfkit/pdfkit.py", line 201, in to_pdf
    self.handle_error(exit_code, stderr)
  File "env/lib/python3.10/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: SslHandshakeFailedError
super@localhost:~/test$ wkhtmltopdf -V
wkhtmltopdf 0.12.6 (with patched qt)
1 Like

i add set this record to {site}/site_config.json

"host_name": "http://127.0.0.1:8000",

Then it’s worked!

6 Likes

I had:
OSError: wkhtmltopdf reported an error:
Exit with code 1 due to network error: ConnectionRefusedError
and that fixed it.
Thanks.

Thank you a lot
You saved my day :grinning: :grinning:

Hi, Can you elaborate on your solution? with steps.

On your server, access the site_config.json file located at:

frappe-bench/sites/{yoursitenamehere}/site_config.json

and add the following line:

"host_name": "http://127.0.0.1:8000",

The following command will work when your are in your site’s directory to edit site_config.json:

sudo nano site_config.json

It worked for me by adding local IP:

“host_name”: “http://192.168.x.x”,

in site_config.js file

1 Like

any solution for production mode ?

where can i find the site_config.js file in the Django project?

I found this solution/explanation in github, and i had updated my configurator service in compose.yaml which i’m using with a custom image:

bench set-config -g host_name “http://${CUSTOM_IMAGE:-frappe/erpnext}-frontend-1:8080”;

worked perfectly, hope this help someone! :slight_smile:

will this work with

wkhtmltopdf 12.6 version as well ?