Wkhtmltopdf error creating PDF

Hello, i am trying to convert into pdf, and i get this error:

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

Here is a screen for the error: https://nimb.ws/6Xvgi7

Hi,

See if the solution mentioned here works:

https://discuss.frappe.io/t/oserror-wkhtmltopdf-reported-an-error-exit-with-code-1-due-to-network-error-sslhandshakefailederror/96029

Hello @smino thank you for the answer, after adding the host at config, now i get this error:

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

AND

frappe.exceptions.ValidationError: PDF generation failed because of broken image links

here is a screen: https://nimb.ws/BujwXb

any idea?

Hi,

Please describe the operating environment. Host OS and how ERPNext was deployed. What is producing the error?

I have used the docker installation as described on github. Production environment.
I am trying to create PDF from invoice.
wkhtmltopdf 0.12.6 (with patched qt), this is installed on the docker (output from wkhtmltopdf -V)

I haven’t tried the docker method yet. Can you post the site_config.json for the site and docker inspect for the container? Hopefully One with better understanding of Docker will jump in.

Sure
Here is the site config

{
 "db_name": "11",
 "db_password": "11",
 "db_type": "mariadb",
 "encryption_key": "111=",
 "user_type_doctype_limit": {
  "employee_self_service": 20
 }
}

Also the container inspect

{
	"Id": "cc88a275671104df94418ae1e748bd984c69be548e5210c01ea539dea0b78a73",
	"Created": "2023-03-04T17:55:10.184275471Z",
	"Path": "/home/frappe/frappe-bench/env/bin/gunicorn",
	"Args": [
		"--chdir=/home/frappe/frappe-bench/sites",
		"--bind=0.0.0.0:8000",
		"--threads=4",
		"--workers=2",
		"--worker-class=gthread",
		"--worker-tmp-dir=/dev/shm",
		"--timeout=120",
		"--preload",
		"frappe.app:application"
	],
	"State": {
		"Status": "running",
		"Running": true,
		"Paused": false,
		"Restarting": false,
		"OOMKilled": false,
		"Dead": false,
		"Pid": 8440,
		"ExitCode": 0,
		"Error": "",
		"StartedAt": "2023-03-04T17:55:28.058646598Z",
		"FinishedAt": "0001-01-01T00:00:00Z"
	},
	"Image": "sha256:d554351b590e88b778fbd16f9260a94b212f6793aadb6e1a4294218f5ecbd4ea",
	"ResolvConfPath": "/var/lib/docker/containers/cc88a275671104df94418ae1e748bd984c69be548e5210c01ea539dea0b78a73/resolv.conf",
	"HostnamePath": "/var/lib/docker/containers/cc88a275671104df94418ae1e748bd984c69be548e5210c01ea539dea0b78a73/hostname",
	"HostsPath": "/var/lib/docker/containers/cc88a275671104df94418ae1e748bd984c69be548e5210c01ea539dea0b78a73/hosts",
	"LogPath": "/var/lib/docker/containers/cc88a275671104df94418ae1e748bd984c69be548e5210c01ea539dea0b78a73/cc88a275671104df94418ae1e748bd984c69be548e5210c01ea539dea0b78a73-json.log",
	"Name": "/erp-boost-backend-1",
	"RestartCount": 0,
	"Driver": "overlay2",
	"Platform": "linux",
	"MountLabel": "",
	"ProcessLabel": "",
	"AppArmorProfile": "docker-default",
	"ExecIDs": [
		"3b8c868227433fff517fd178389dab608969334441aaf66c30351332cf05687d",
		"9635e345bd073d637ba25c63f5c972390921abbc491abc3ae086b939741a74ae",
		"6a04c4284dae629d515dd24c7e8a02ce135676f461d2be8f5f541b3afd5648b9",
		"11baf917703d388b0cc863b0c45e75004c40c31efa267fe6f50d3adce69d45f8",
		"6f487bf980c4b36a47dd73b26c4e01ad476f31c94c8986ffbff97cab4e6cc5ba",
		"acd8a965b622f4aa75267625fbf8eaf8f9e274c0a386c605ae8b004efb9a0e73",
		"c77873b67553e8f71e2114f7aca1324126235471ad600acea420c03d8b8906a2",
		"d045efeb8496a23192a0235596ebf06b7d28a93e492de4a766c60407f79393fc",
		"bfbd3e4fd2e9a8f3b4044196fe1728b9cae97a98abd2b97c18421840ef11dbb6",
		"4249604fed0e72edc14b2533932c3cafc2c0e3d6b83b9916272ca9d8b26f6da1",
		"bb66e1814fbb40ee69894253c206708c3cf94246303e951d530128bd4692844f"
	],
	"HostConfig": {
		"Binds": null,
		"ContainerIDFile": "",
		"LogConfig": {
			"Type": "json-file",
			"Config": {}
		},
		"NetworkMode": "frappe_docker_default",
		"PortBindings": {},
		"RestartPolicy": {
			"Name": "",
			"MaximumRetryCount": 0
		},
		"AutoRemove": false,
		"VolumeDriver": "",
		"VolumesFrom": null,
		"CapAdd": null,
		"CapDrop": null,
		"CgroupnsMode": "host",
		"Dns": null,
		"DnsOptions": null,
		"DnsSearch": null,
		"ExtraHosts": [],
		"GroupAdd": null,
		"IpcMode": "private",
		"Cgroup": "",
		"Links": null,
		"OomScoreAdj": 0,
		"PidMode": "",
		"Privileged": false,
		"PublishAllPorts": false,
		"ReadonlyRootfs": false,
		"SecurityOpt": null,
		"UTSMode": "",
		"UsernsMode": "",
		"ShmSize": 67108864,
		"Runtime": "runc",
		"ConsoleSize": [
			0,
			0
		],
		"Isolation": "",
		"CpuShares": 0,
		"Memory": 0,
		"NanoCpus": 0,
		"CgroupParent": "",
		"BlkioWeight": 0,
		"BlkioWeightDevice": null,
		"BlkioDeviceReadBps": null,
		"BlkioDeviceWriteBps": null,
		"BlkioDeviceReadIOps": null,
		"BlkioDeviceWriteIOps": null,
		"CpuPeriod": 0,
		"CpuQuota": 0,
		"CpuRealtimePeriod": 0,
		"CpuRealtimeRuntime": 0,
		"CpusetCpus": "",
		"CpusetMems": "",
		"Devices": null,
		"DeviceCgroupRules": null,
		"DeviceRequests": null,
		"KernelMemory": 0,
		"KernelMemoryTCP": 0,
		"MemoryReservation": 0,
		"MemorySwap": 0,
		"MemorySwappiness": null,
		"OomKillDisable": false,
		"PidsLimit": null,
		"Ulimits": null,
		"CpuCount": 0,
		"CpuPercent": 0,
		"IOMaximumIOps": 0,
		"IOMaximumBandwidth": 0,
		"Mounts": [
			{
				"Type": "volume",
				"Source": "frappe_docker_sites",
				"Target": "/home/frappe/frappe-bench/sites",
				"VolumeOptions": {}
			}
		],
		"MaskedPaths": [
			"/proc/asound",
			"/proc/acpi",
			"/proc/kcore",
			"/proc/keys",
			"/proc/latency_stats",
			"/proc/timer_list",
			"/proc/timer_stats",
			"/proc/sched_debug",
			"/proc/scsi",
			"/sys/firmware"
		],
		"ReadonlyPaths": [
			"/proc/bus",
			"/proc/fs",
			"/proc/irq",
			"/proc/sys",
			"/proc/sysrq-trigger"
		]
	},
	"GraphDriver": {
		"Data": {
			"LowerDir": "/var/lib/docker/overlay2/1065b84d0616e7139bb00e090fe86ed88da9c6a27f7859ac21649b4510f49e7b-init/diff:/var/lib/docker/overlay2/4c7202a62fc0c4c1dc6d17f9d05edb652f12a3c97758077d55bb04fab2091976/diff:/var/lib/docker/overlay2/29d1277c2afb108693a2c8e13bef3c1ab5606e416fc9ecfeeb14c3007051bd82/diff:/var/lib/docker/overlay2/b57a4544de09ad0958c2bbcae12ef02c8ece71209c2631d29eda96a355c4ed38/diff:/var/lib/docker/overlay2/5846a21f03c31f063ba14109c716eb16112486ae5f6aabb5f86fde704561da56/diff:/var/lib/docker/overlay2/86e409726e37ea2ce98345024377644dd4d9f9f9eae0d2ca71312b736ac39cb0/diff:/var/lib/docker/overlay2/0a9caf1c1b9b764104a60ba7bd8d04bf6d209ee7f6e610a40423f324394a31a7/diff:/var/lib/docker/overlay2/6a4debb733e890edc700ff056de03d6d664021f7aa5fe3d6381dda69a1f7835a/diff:/var/lib/docker/overlay2/0bfe277db050c38d234124c2a076eed5e2e1c27cf41419066c26715e4b5ead13/diff:/var/lib/docker/overlay2/b4e6e5ec07759ac6fdebca9fc3ce4401da38ef9cb2a2375527acfb94aa3867cb/diff:/var/lib/docker/overlay2/41866150b1714677156f624ee74fe06bf5d619f8a0666f4bdb2ae9fa8820b88f/diff",
			"MergedDir": "/var/lib/docker/overlay2/1065b84d0616e7139bb00e090fe86ed88da9c6a27f7859ac21649b4510f49e7b/merged",
			"UpperDir": "/var/lib/docker/overlay2/1065b84d0616e7139bb00e090fe86ed88da9c6a27f7859ac21649b4510f49e7b/diff",
			"WorkDir": "/var/lib/docker/overlay2/1065b84d0616e7139bb00e090fe86ed88da9c6a27f7859ac21649b4510f49e7b/work"
		},
		"Name": "overlay2"
	},
	"Mounts": [
		{
			"Type": "volume",
			"Name": "frappe_docker_sites",
			"Source": "/var/lib/docker/volumes/frappe_docker_sites/_data",
			"Destination": "/home/frappe/frappe-bench/sites",
			"Driver": "local",
			"Mode": "z",
			"RW": true,
			"Propagation": ""
		},
		{
			"Type": "volume",
			"Name": "2b76cf9fffa7981ce82a975fe67bdc3db4cf7e527101ace7492e15dbc40c9720",
			"Source": "/var/lib/docker/volumes/2b76cf9fffa7981ce82a975fe67bdc3db4cf7e527101ace7492e15dbc40c9720/_data",
			"Destination": "/home/frappe/frappe-bench/logs",
			"Driver": "local",
			"Mode": "",
			"RW": true,
			"Propagation": ""
		},
		{
			"Type": "volume",
			"Name": "b27fb46d79e8203bcd6146a04878e831f186867d34df6319f88408160cec6373",
			"Source": "/var/lib/docker/volumes/b27fb46d79e8203bcd6146a04878e831f186867d34df6319f88408160cec6373/_data",
			"Destination": "/home/frappe/frappe-bench/sites/assets",
			"Driver": "local",
			"Mode": "",
			"RW": true,
			"Propagation": ""
		}
	],
	"Config": {
		"Hostname": "cc88a2756711",
		"Domainname": "",
		"User": "frappe",
		"AttachStdin": false,
		"AttachStdout": true,
		"AttachStderr": true,
		"Tty": false,
		"OpenStdin": false,
		"StdinOnce": false,
		"Env": [
			"PATH=/home/frappe/.nvm/versions/node/v16.18.0/bin/:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
			"LANG=C.UTF-8",
			"GPG_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D",
			"PYTHON_VERSION=3.10.5",
			"PYTHON_PIP_VERSION=22.0.4",
			"PYTHON_SETUPTOOLS_VERSION=58.1.0",
			"PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/49ca29908cfd49683da12f2d5a4fa5689539f9d9/public/get-pip.py",
			"PYTHON_GET_PIP_SHA256=d077d469ce4c0beaf9cc97b73f8164ad20e68e0519f14dd886ce35d053721501",
			"NVM_DIR=/home/frappe/.nvm"
		],
		"Cmd": [
			"/home/frappe/frappe-bench/env/bin/gunicorn",
			"--chdir=/home/frappe/frappe-bench/sites",
			"--bind=0.0.0.0:8000",
			"--threads=4",
			"--workers=2",
			"--worker-class=gthread",
			"--worker-tmp-dir=/dev/shm",
			"--timeout=120",
			"--preload",
			"frappe.app:application"
		],
		"Image": "us-east-1.amazonaws.com/boosterp:1.6",
		"Volumes": {
			"/home/frappe/frappe-bench/logs": {},
			"/home/frappe/frappe-bench/sites": {},
			"/home/frappe/frappe-bench/sites/assets": {}
		},
		"WorkingDir": "/home/frappe/frappe-bench",
		"Entrypoint": null,
		"OnBuild": null,
		"Labels": {
			"com.docker.compose.config-hash": "67211d54d3060e592783de51ee24cc416a35be661327ee09c90b79b69ea3bfdd",
			"com.docker.compose.container-number": "1",
			"com.docker.compose.depends_on": "configurator:service_completed_successfully",
			"com.docker.compose.image": "sha256:d554351b590e88b778fbd16f9260a94b212f6793aadb6e1a4294218f5ecbd4ea",
			"com.docker.compose.oneoff": "False",
			"com.docker.compose.project": "erp-boost",
			"com.docker.compose.project.config_files": "/home/debian/gitops/docker-compose.yml",
			"com.docker.compose.project.working_dir": "/home/debian/gitops",
			"com.docker.compose.service": "backend",
			"com.docker.compose.version": "2.16.0"
		}
	},
	"NetworkSettings": {
		"Bridge": "",
		"SandboxID": "ef52175392afed925fd2e4aa8e00c8b4ad65dd038213377fc4a6a56031b18a73",
		"HairpinMode": false,
		"LinkLocalIPv6Address": "",
		"LinkLocalIPv6PrefixLen": 0,
		"Ports": {},
		"SandboxKey": "/var/run/docker/netns/ef52175392af",
		"SecondaryIPAddresses": null,
		"SecondaryIPv6Addresses": null,
		"EndpointID": "",
		"Gateway": "",
		"GlobalIPv6Address": "",
		"GlobalIPv6PrefixLen": 0,
		"IPAddress": "",
		"IPPrefixLen": 0,
		"IPv6Gateway": "",
		"MacAddress": "",
		"Networks": {
			"frappe_docker_default": {
				"IPAMConfig": null,
				"Links": null,
				"Aliases": [
					"erp-boost-backend-1",
					"backend",
					"cc88a2756711"
				],
				"NetworkID": "fc25b410d44c6ca05c19b7d4ddbbc6f88567423a24b9394ef09f65e4f9ff5866",
				"EndpointID": "9b43e190bf79f78af3b8551e05125385e9e14e16b8899227a6b54c06bc8af514",
				"Gateway": "172.25.0.1",
				"IPAddress": "172.25.0.12",
				"IPPrefixLen": 16,
				"IPv6Gateway": "",
				"GlobalIPv6Address": "",
				"GlobalIPv6PrefixLen": 0,
				"MacAddress": "02:42:ac:119:00:0c1",
				"DriverOpts": null
			}
		}
	},
	"Ports": []
}

Again, the site_config may need a “host_name”: “http://127.0.0.1:80” (with the correct ip and port) added .

Thank you for your support.
I had the 2 problems, wrong port 8000 and pdf error when trying to generate.
At common_site_config.json, i changed this lines:

 "restart_supervisor_on_update": true,
 "restart_systemd_on_update": true,
"host_name": "https://mydomain.com"

Restarted all dockers, and issues were fixed.
ERPnext is great, thank you
Best

PS: @smino at the container info i posted, is there any sensitive data ?

1 Like

I don’t believe so, someone else may correct me though.

1 Like