title: How to run selenium test on aws ec2 server
body: <p>i have dome with some basic selenium test and it is working fine on local machine, now i want ot run it on aws ec2 server ( Amazon Server). I have install selenium, firefox and other required libraries on aws but when i am running my code on aws i am getting some error that "Could not start a new session". </p>
  
  <p><strong>My small selenium code</strong></p>
  
  <pre><code>    String platform_name = "linux";
      String browser_name = "firefox";
      String browser_version = "41";
      DesiredCapabilities capabilities = new DesiredCapabilities();
      capabilities.setPlatform(Platform.LINUX);
      capabilities.setBrowserName(browser_name);
      capabilities.setVersion(browser_version);
      RemoteWebDriver driver = new RemoteWebDriver(new URL("http://ec2-52-34-44-185.us-west-2.compute.amazonaws.com:4444/wd/hub"),capabilities);
      System.out.print("url has been openening now...");
      driver.get("http://google.com");
      System.out.print("url has been open");
      driver.quit();
  </code></pre>
  
  <p><strong>Here is error which i am getting</strong></p>
  
  <pre><code>Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
  Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 02:56:46'
  System info: host: 'napendra-PC', ip: '192.168.0.67', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_79'
  Driver info: driver.version: RemoteWebDriver
      at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:589)
      at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
      at org.openqa.selenium.remote.RemoteWebDriver.&lt;init&gt;(RemoteWebDriver.java:128)
      at org.openqa.selenium.remote.RemoteWebDriver.&lt;init&gt;(RemoteWebDriver.java:155)
      at Demo.main(Demo.java:20)
  Caused by: org.apache.http.conn.HttpHostConnectException: Connect to ec2-52-34-44-185.us-west-2.compute.amazonaws.com:4444 [ec2-52-34-44-185.us-west-2.compute.amazonaws.com/52.34.44.185] failed: Connection timed out: connect
      at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
      at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
      at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
      at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
      at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
      at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
      at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
      at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
      at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
      at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
      at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:143)
      at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:89)
      at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:134)
      at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:568)
      ... 4 more
  Caused by: java.net.ConnectException: Connection timed out: connect
      at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
      at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
      at java.net.Socket.connect(Socket.java:579)
      at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)
      at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
      ... 17 more
  </code></pre>