[š Bug]: "Invalid Host Header" in Firefox 106 w/ geckodriver 0.32.0
See original GitHub issueWhat happened?
Iām using Firefox 106 with selenium-firefox-driver:4.5.0
for Java and geckodriver 0.32.0 (via Selenide 6.9.0)
Selenium GeckoDriverService
launches geckodriver
and when starting a new browser session it calls PUT http://localhost:<port>/session
However, since the --allow-hosts localhost
flag is not provided when starting geckodriver
, requests to geckodriver always return 500 Invalid Host Header
Source of geckodriver
arguments:
Source of target url for reqeusts to geckodriver
:
My suggestion would be to update GeckoDriverService
to either include --allow-hosts localhost
or override ::getPort(int)
to http://127.0.0.1:%d
.
How can we reproduce the issue?
Breaks 100% of the time with the specified versions:
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
public class Main {
public static void main(String[] args) throws Exception {
var options = new FirefoxOptions();
System.setProperty("webdriver.gecko.driver", "/usr/bin/geckodriver"); // geckodriver 0.32.0
options.setBinary("/usr/bin/firefox"); // firefox 106 installed
var driver = new FirefoxDriver(options);
driver.get("https://www.stackoverflow.com");
}
}
Relevant log output
1668526366108 geckodriver INFO Listening on 127.0.0.1:55726
1668526366212 webdriver::server WARN Rejected request with Host header localhost:55726, allowed values are []
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: Invalid Host header localhost:55726
Operating System
linux
Selenium version
java 4.5.0
What are the browser(s) and version(s) where you see this issue?
Firefox 106
What are the browser driver(s) and version(s) where you see this issue?
geckodriver 0.32.0
Issue Analytics
- State:
- Created 10 months ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
1750691 - Release geckodriver 0.32.0 - Bugzilla@Mozilla
Bug 1750691 - [geckodriver] Update changeset for the 0.32.0 release. 2 months ago ... Bug 1750691 - [geckodriver] Release version 0.32.0. 2 months...
Read more >python - Invalid Host header localhost - Stack Overflow
I am getting the following error. /home/USER/workspace/PycharmProjects/linkedinkeywords/venv/bin/python /usr/share/pycharm/plugins/pythonĀ ...
Read more >Bug List - FreeBSD Bugzilla
ID Productā³ Componentā³ Assigneeā½ Statusā½ Resolutionā³ Changed
163568 Base System amd64 amd64 Closed Not Enough Info 2016ā01ā02
259438 Base System arm freebsdāarm Open āāā 2021ā10ā25
236373...
Read more >ChangeLog.txt - SlackBuilds.org
New maintainer. libraries/libbsd: Updated for version 0.11.6. libraries/libcurl-gnutls: Patched to fix fatal error. libraries/libfm-qt: Added (PCManFM-QtĀ ...
Read more >Compare Packages Between Distributions - DistroWatch.com
Often times it is useful to be able to compare the versions of different packages between two distributions. This can let us know...
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
Well, you should be able to create your own
GeckoDriverService
with the arguments specified, but I havenāt tested it to see if they get overridden somewhere (FirefoxService code is a bit weird for legacy reasons). The code itself encourages using the Builder, though, and that doesnāt support adding arguments. I want us to do a review of it all soon.@diemol To be honest, I donāt think this is a misconfig. Yes, I was able to work around the issue by updating my system configuration. However, if you ask me, having an empty
/etc/hosts
file is not a misconfiguration - itās even the default on my distro.I donāt know if itās necessary to change this within selenium per-se. But in my opinion there should at least be a way to pass additional parameters to
geckodriver
for cases like this. Right now, I can set parameters to launchfirefox
viaFirefoxOptions
, but notgeckodrvier
itself.If I had no su access to the machine I am working on, I wouldnāt have been able to resolve this.