WSL2 refusing to connect to chrome.exe
See original GitHub issueSteps to reproduce
- Puppeteer version:
puppeteer||puppeteer-core3.2.0 - Chrome Version: 83.0.4103.61 (Official Build)
- Platform / OS version: Windows 10 WSL2 Ubuntu 20.04
- Node.js version: 14.3.0
What steps will reproduce the problem?
Run the following commands:
~ $ export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
~ $ mkdir puppeteer-test
~ $ cd puppeteer-test
puppeteer-test $ npm install puppeteer
puppeteer-test $ nano index.mjs
# insert code from below
puppeteer-test $ node index.mjs
index.mjs
import puppeteer from 'puppeteer'
void async function main() {
const browser = await puppeteer.launch({
headless: false,
executablePath: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',
})
const page = await browser.newPage()
await page.goto('https://google.com')
await new Promise(res => setTimeout(res, 10000))
await browser.close()
}()
What is the expected result?
Expect the (Windows) browser to open puppeteer to connect navigate to google wait 10 seconds close the browser
What happens instead?
The browser opens, node crashes, emits an error then exits
ErrorEvent {
target: WebSocket {
_events: [Object: null prototype] { open: [Function], error: [Function] },
_eventsCount: 2,
_maxListeners: undefined,
readyState: 3,
protocol: '',
_binaryType: 'nodebuffer',
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_closeCode: 1006,
_extensions: {},
_receiver: null,
_sender: null,
_socket: null,
_bufferedAmount: 0,
_isServer: false,
_redirects: 0,
url: 'ws://127.0.0.1:50887/devtools/browser/1b50d3bc-6f08-4611-89da-471711ae4672',
_req: null,
[Symbol(kCapture)]: false
},
type: 'error',
message: 'connect ECONNREFUSED 127.0.0.1:50887',
error: Error: connect ECONNREFUSED 127.0.0.1:50887
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 50887
}
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:6
Top Results From Across the Web
ChromeDriver in WSL2 - Greg Brisebois
The X Server Download and install VcXsrv in Windows. Once installed, run xlaunch.exe (from the VcXsrv folder in Program Files). You can leave ......
Read more >Live Server does not open in Chrome on Windows 11 and ...
You can use this command to find it: sudo find /mnt/c/ -type f -iname chrome.exe 2>&1 | grep -v "Permission denied" .
Read more >Chromium not opening in WSL2 - chrome
In WSL1, people can not use a Linux version of Chrome. so just use Windows version chrome.exe and chromdriver.exe .
Read more >Some apps in WSL are inaccessible from the host OS while ...
Running headless Chrome with --remote-debugging-port . Chrome on the host OS is unable to connect to the headless Chrome in WSL. What I...
Read more >Connecting Puppeteer to Existing Chrome Window w
How To: Connect Puppeteer to existing Chrome Window in order to build ... "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It seems WSL2 is unable to access http servers located in Windows. I have created an issue in the Microsoft WSL github and will follow up here for viability once resolved.
I am able to specify the address and port of the WSL port and host in chrome’s args
however it seems that Chrome rejects the connection. Perhaps due to firewall settings. I have read elsewhere that Chrome disallows connections that are not from “localhost”.
I was unsuccessful in launching Chrome, but is
pipe: truean option?pipe failed too. ProtocolError: Protocol error (Target.setAutoAttach): Target closed.