Frappe Docker OSError: wkhtmltopdf reported an error: network error: HostNotFoundError

I am testing the recent 2023 frappe docker with custom image.
While printing to pdf i am getting the below error.

Any Idea how to fix this.

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 69, 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 1590, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/utils/print_format.py", line 129, in download_pdf
    pdf_file = frappe.get_print(
  File "apps/frappe/frappe/__init__.py", line 2023, in get_print
    return get_pdf(html, options=pdf_options, output=output)
  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: HostNotFoundError

Regards,
Arun

some of the rendered url locations for images may be unavailable. e.g. if your print renders some external url location?

in case of production setup where the url is actual available site, it renders the location. if you’re using it locally e.g. http://site1.localhost/files/some.png then the container which is rendering the pdf will not find anything at that location.

Thanks @revant_one for the direction.

In this case it is simple print without any images. No Letter head and no footer included.

I tried both site1.docker.localhost and on actual domain. site1.mydomain.com

in the docker.localhost version, the above mentioned error is immediately thrown when we invoke pdf from print

in the actual site, it is timing out. When tried to send emails with attachments the below error is captured.

 File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 135, in send
    message = ctx.build_message(recipient.recipient)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 294, in build_message
    message = self.include_attachments(message)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_queue/email_queue.py", line 353, in include_attachments
    print_format_file = frappe.attach_print(**attachment)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 2070, in attach_print
    content = get_print(doctype, name, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 2023, in get_print
    return get_pdf(html, options=pdf_options, output=output)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/pdf.py", line 38, in get_pdf
    filedata = pdfkit.from_string(html, options=options or {}, verbose=True)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pdfkit/api.py", line 75, in from_string
    return r.to_pdf(output_path)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pdfkit/pdfkit.py", line 197, in to_pdf
    stdout, stderr = result.communicate(input=input)
  File "/usr/local/lib/python3.10/subprocess.py", line 1152, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/usr/local/lib/python3.10/subprocess.py", line 2003, in _communicate
    ready = selector.select(timeout)
  File "/usr/local/lib/python3.10/selectors.py", line 416, in select
    fd_event_list = self._selector.poll(timeout)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/rq/timeouts.py", line 61, in handle_death_penalty
    raise self._exception('Task exceeded maximum timeout value '

Regards,
Arun

I tried pwd again, I was able to print Note.

In pwd it is working fine.
Like in the reference post i do get same error after adding the host to site configuration in site1.docker.localhost.
I am still wondering which image the pdf is referring to as the doctype has no image field in it.

I will do further analysis. Meanwhile any directions on this issue, please help

note: the custom image is built using GitHub - castlecraft/custom_containers

Kind Regards,
Arun

I tested the my previous docker.localhost versions. the result is the same error. This is not the regression issue with 2023 frappe_docker.

I will create a new thread in which I am facing two issues with production setup.