When you run a Selenium script, it starts a local executable called GeckoDriver . This executable acts as the bridge between your code and the Firefox browser. Selenium tries to connect to this bridge via a local network address (usually
Cannot start the driver service on http localhost — Selenium + Firefox (C#) If you see an error like “cannot start the driver service on http://localhost:xxxxx” when using Selenium with Firefox in C#, this note explains common causes and fixes. Likely causes
Geckodriver executable missing or not found — Selenium cannot locate the geckodriver binary. Wrong geckodriver version — geckodriver and Firefox versions are incompatible. Port already in use or blocked — requested localhost port is occupied or prevented by firewall. Insufficient permissions — process cannot start the executable due to file permissions or antivirus blocking. Incorrect driver start arguments or service config — wrong path, working directory, or options passed to FirefoxDriverService. 32-bit vs 64-bit mismatch — binary architecture mismatch on some environments. Environment PATH issues — PATH not updated, or running in restricted environment (CI, Docker) without DISPLAY or proper capabilities. Geckodriver locked by a previous process — previous driver instance not closed and holding resources.
Quick checklist (apply in order)
Ensure geckodriver exists and is executable:
Download matching geckodriver for your OS and Firefox version. Place it in your project or a known folder and set executable permissions (chmod +x on Linux/macOS).
Point Selenium to the driver explicitly: When you run a Selenium script, it starts
Use FirefoxDriverService.CreateDefaultService(pathToDriver) or new FirefoxDriver(service, options).
Match versions:
Update Firefox and geckodriver so they’re compatible. Likely causes Geckodriver executable missing or not found
Ensure port availability:
Reboot or kill lingering geckodriver/geckodriver-child processes. Temporarily disable firewall/antivirus to test.