gildas-lormeau / single-file-cli

CLI tool for saving a faithful copy of a complete web page in a single HTML file (based on SingleFile)
GNU Affero General Public License v3.0
602 stars 63 forks source link

Error sending request for url; Connection refused (os error 111) #76

Closed jiatern closed 6 months ago

jiatern commented 6 months ago

Hi, I am using the latest release v2.0.19 on Debian. Previously I was using the old v1.xx and had no problems until today when it started to show errors with chrome, so I updated to v2.0.19.

However running single-file https://www.wikipedia.org wikipedia.html gives me the following error:

error sending request for url (http://localhost:9222/json/new?about:blank): error trying to connect: tcp connect error: Connection refused (os error 111) URL: https://www.wikipedia.org
Stack: TypeError: error sending request for url (http://localhost:9222/json/new?about:blank): error trying to connect: tcp connect error: Connection refused (os error 111)
    at async mainFetch (ext:deno_fetch/26_fetch.js:170:12)
    at async fetch (ext:deno_fetch/26_fetch.js:391:7)
    at async https://jsr.io/@simple-cdp/simple-cdp/1.8.2/mod.js:214:24
    at async retryConnection (https://jsr.io/@simple-cdp/simple-cdp/1.8.2/mod.js:233:16)
    at async Module.getPageData (file:///Users/gildas/Desktop/Dev/project-single-file/single-file-cli/lib/cdp-client.js:46:22)
    at async capturePage (file:///Users/gildas/Desktop/Dev/project-single-file/single-file-cli/single-file-cli-api.js:244:20)
    at async runNextTask (file:///Users/gildas/Desktop/Dev/project-single-file/single-file-cli/single-file-cli-api.js:164:20)
    at async Promise.all (index 0)
    at async capture (file:///Users/gildas/Desktop/Dev/project-single-file/single-file-cli/single-file-cli-api.js:115:2)
    at async run (file:///Users/gildas/Desktop/Dev/project-single-file/single-file-cli/single-file-launcher.js:82:3)

Any ideas?

gildas-lormeau commented 6 months ago

I tried to reproduce the issue in Debian 12.5 but I wasn't able to do so. What is the version of Chromium on your system?

jiatern commented 6 months ago

I tried both chrome v114 and v123 (latest stable), same result. I also tried on another VPS on Ubuntu 22.04.3, same result too.

The only thing I did was to download single-file-x86_64-linux, make it executable and make sure chrome is installed. I also tried to directly point to a chromedriver executable file using --browser-executable-path. Still the same error.

Did I miss any step? It works fine on windows however. On the other note, on windows, it seems like it can no longer convert a .html file with local assets folder to a single HTML file. It used to work with the v1.x of single-file-cli.

gildas-lormeau commented 6 months ago

I did a test with single-file-x86_64-linux in Ubuntu but it worked as expected. Maybe you configured your firewall (or something similar) to block connections to localhost?

--browser-executable-path can be used to set the path to the executable file of the Chromium-based browser. The new version (2.x) does not rely on chromedriver.

jiatern commented 6 months ago

Hmm not sure what went wrong in both of my environments, but I managed to get 1.1.x version working again. Since I need the feature to convert offline html + assets to a single html, I will stay with 1.1.x.

Thanks for your help!

gildas-lormeau commented 6 months ago

I was able to reproduce the issue related to pages opened from the filesystem. The fix will be available in the next version.

pellaeon commented 2 months ago

Hi, I encountered the same issue, after some debugging I realized it's because my deno was installed using Ubuntu Snap, using the non-Snap version works. Just FYI in case someone also uses the deno Snap.