Shannon McRae
Shannon McRae

Reputation: 245

Host header or origin header is specified and is not localhost for selenium grid

I am trying to set up a selenium grid using the latest chrome and chromedriver. I get the following error when trying to run a test

Message: OpenQA.Selenium.WebDriverException : Unexpected error. Host header or origin header is specified and is not localhost.

On the node machine, I see the chrome browser open, but then it immediately closes and I get this error:

[1557513678.682][SEVERE]: Rejecting request with host: <hub_IP_address>:4444

Has anyone had this issue using the selenium grid? I am using:

Here is my command for starting the hub:

java -jar selenium-server-standalone-4.0.0-alpha-1.jar -role hub -hubConfig config.json

Here is my command to start a node:

java -Dwebdriver.chrome.driver="C:\...\Browsers\ChromeDirectory\chromedriver.exe" -Dwebdriver.ie.driver="C:\...\Browsers\IEDirectory\x86\IEDriverServer.exe" -jar -Dwebdriver.edge.driver="C:\...\Browsers\Edge\MicrosoftWebDriver.exe" -jar "C:\...\selenium-server-standalone-4.0.0-alpha-1.jar" -role node -hub "http://<hub_IP_address>:4444/grid/register/" -nodeConfig "C:\...\config.json"

I tried using a "host" property in the config.jsons. I tried putting the actual IP address and just localhost. But the hub and the node are obviously different machines, so putting localhost makes it so they can't connect. But when I dont have localhost, it says it needs to be specified as localhost? I'm so confused!! What is supposed to go in the host property?

I have seen people talk about a loopback property for protractor but I am not using protractor. I tried putting "loopback":true into both my node and hub config.json files but it doesn't seem to make a difference.

UPDATE: I was able to get the grid to run successfully using the 4.0 alpha jar for the hub, and the old 3.8 jars for the nodes. All Still on Java 8. Kind of interesting.

Upvotes: 3

Views: 4458

Answers (2)

emksk
emksk

Reputation: 101

You can try to add these switches: --whitelisted-ips --allowed-origins=''*

Try to run your node with command:

java -Dwebdriver.chrome.driver="C:\...\Browsers\ChromeDirectory\chromedriver.exe --whitelisted-ips --allowed-origins='*'" -Dwebdriver.ie.driver="C:\...\Browsers\IEDirectory\x86\IEDriverServer.exe" -jar -Dwebdriver.edge.driver="C:\...\Browsers\Edge\MicrosoftWebDriver.exe" -jar "C:\...\selenium-server-standalone-4.0.0-alpha-1.jar" -role node -hub "http://<hub_IP_address>:4444/grid/register/" -nodeConfig "C:\...\config.json"

Upvotes: 4

Shannon McRae
Shannon McRae

Reputation: 245

I was able to get the selenium grid working by downgrading to 3.8.1 selenium grid jar and installing JDK 8 instead of 12. The reason I needed to get java 8 is answered in this other question. I used the same chrome driver and start up commands

Upvotes: -1

Related Questions