question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Host header is specified and is not an IP address or localhost.

See original GitHub issue
Component Version
Operating system Ubuntu 16.04
Node.js 8.11.1
Chrome/Chromium/… 66.0.3359.117
chrome-remote-interface 0.25.5

Is Chrome running in a container? YES

Getting the error in the latest version of stable chrome

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

7reactions
tpaicommented, Jan 27, 2021

In my case, I used k8s service name as the link URL, so I bypass the restriction by using DNS lookup to turn host name to IP address, then use it to connect the headless chrome instance.

const dns = require('dns').promises;

const { address } = await dns.lookup("chrome-service", {
  family: 4,
  hints: dns.ADDRCONFIG,
});

const browser = await puppeteer.connect({
  browserURL: `http://${address}:9222`,
});

It works.

3reactions
cyrus-andcommented, Apr 26, 2018

how to override the default host header?

Like this:

--- a/lib/external-request.js
+++ b/lib/external-request.js
@@ -4,6 +4,7 @@ const REQUEST_TIMEOUT = 10000;

 // callback(err, data)
 function externalRequest(transport, options, callback) {
+    options.headers = {host: 'localhost'};
     const request = transport.get(options, function (response) {
         let data = '';
         response.on('data', function (chunk) {

if we can regenerated webSocketDebuggerUrl for temporary workaround, can be work?

It could be but since the webSocketDebuggerUrl issue appears to be a bug of Chrome I would wait a response from the Chromium team.


The simplest workaround is IMHO using the IP address directly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Host header is specified and is not an IP address or localhost ...
This specific issue is not unique to Cloud Run. It originates from an existing change in the Chrome DevTools Protocol which generates this ......
Read more >
Host header or origin header is specified and is not whitelisted ...
I need to use the IP 172.17.0.1 (instead of the usual localhost) since I need to run chromedriver in a Docker container, and...
Read more >
Host header is specified and is not an IP address or localhost
So starting from version 66 Chrome stops accepting HTTP connections to the debugging protocol server if the "host header is specified and is...
Read more >
Host Header - What is an HTTP Host Header injection?
The HTTP host header is a request header that specifies the domain that a client (browser) wants to access. This header is necessary...
Read more >
Trusted Host settings | Installing Drupal
If the Host header of the HTTP request does not match the defined ... (or localhost IP address, 127.0.01 in this example) to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found