org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost error with IEDriverServer

srikanth picture srikanth · Mar 28, 2018 · Viewed 19.5k times · Source

I have tried IE launch in webdriver as below, I have checked all protected mode settings in security tab of Internet Options, zoom level is 100%, environment variable even set, But not able to launch IE browser in the simple selenium code; Errors seen as Failed to connect to local host though gave url http://google.co.in and Caused by: java.net.ConnectException: Connection refused: Can someone please help me out with this issue. Thank you in advance

package eHMS_package;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class EHMS_Login {

    public WebDriver driver;

    public static void main(String[] args)
    {
        System.setProperty("webdriver.ie.driver", "E:/SRIKANTH/IEDriver/IEDriverServer.exe");
        WebDriver driver = new InternetExplorerDriver();
        driver.navigate().to("http://google.co.in");
    }
}

Error Details :

Started InternetExplorerDriver server (64-bit)
3.9.0.0 Listening on port 48107 Only local connections are allowed Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:48107 Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z' System info: host: 'UMANATH-PC', ip: '10.1.0.25', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_161' Driver info: driver.version: InternetExplorerDriver    at 

org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
        at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:223)
        at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:215)
        at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:152)
        at eHMS_package.EHMS_Login.main(EHMS_Login.java:15)
    Caused by: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:48107
        at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:240)
        at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:158)
        at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:256)
        at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:134)
        at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:113)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
        at okhttp3.RealCall.execute(RealCall.java:77)
        at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:101)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:101)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
        ... 6 more
    Caused by: java.net.ConnectException: Connection refused: connect
        at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
        at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
        at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
        at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
        at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at okhttp3.internal.platform.Platform.connectSocket(Platform.java:125)
        at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:238)
        ... 28 more

Answer

DebanjanB picture DebanjanB · Mar 28, 2018

The error says it all :

Started InternetExplorerDriver server (64-bit)3.9.0.0 
Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:48107 
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z' 
System info: host: 'UMANATH-PC', ip: '10.1.0.25', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_161' 
Driver info: driver.version: InternetExplorerDriver

It is clear from the error stack trace that InternetExplorerDriver server is not getting detected back as in :

Driver info: driver.version: InternetExplorerDriver

Your main issue is the version compatibility between the binaries you are using as follows :

  • You are using Selenium Client v3.11.0
  • But you are using InternetExplorerDriverServer v3.9.0.0

So there is a clear mismatch between the Selenium Client v3.11.0 and InternetExplorerDriverServer v3.9.0.0.

Solution

  • Upgrade to InternetExplorerDriverServer v3.11.1.0