title: Specify the port ChromeDriver runs
body: <p>H community, I am trying to set up the Selenium Grid on EC2 server, and below are the steps I took so far.</p>
  
  <p>1.start the hub on port 4044</p>
  
  <pre class="lang-sh prettyprint-override"><code>java -jar /ebst/wrangler/upla/bin/selenium-server-standalone-3.141.59.jar -role hub -port 4044
  </code></pre>
  
  <p>2.Register a node on 4045</p>
  
  <pre class="lang-sh prettyprint-override"><code>java -Dwebdriver.chrome.driver="~/chromedriver" -jar ~/selenium-server-standalone-3.141.59.jar -role node -hub http://hubURL:4044/grid/register -port 4045
  </code></pre>
  
  <p>3.Start Webdriver in my Java code</p>
  
  <pre class="lang-java prettyprint-override"><code>import cucumber.api.java.Before;
  import org.openqa.selenium.Platform;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.chrome.ChromeOptions;
  import org.openqa.selenium.remote.DesiredCapabilities;
  import org.openqa.selenium.remote.RemoteWebDriver;
  
  import java.net.MalformedURLException;
  import java.net.URL;
  
  
  public class Test {
      WebDriver driver;
  
      @Before
      public void setup() throws MalformedURLException {
  
          String nodeURL = "http://hubURL:4044/wd/hub";
          System.out.println("setting up");
  
          DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
          desiredCapabilities.setBrowserName("chrome");
  
          desiredCapabilities.setPlatform(Platform.LINUX);
  
          ChromeOptions chromeOptions = new ChromeOptions();
  
          chromeOptions.addArguments(
                  "--verbose",
                  "--headless",
                  "--disable-web-security",
                  "--ignore-certificate-errors",
                  "--allow-running-insecure-content",
                  "--allow-insecure-localhost",
                  "--no-sandbox",
                  "--disable-gpu");
  
          chromeOptions.merge(desiredCapabilities);
  
          driver = new RemoteWebDriver(new URL(nodeURL), chromeOptions);
          System.out.println("setting up done");
  
      }
  }
  </code></pre>
  
  <p>On the console, I got the following error due to timeout.</p>
  
  <blockquote>
    <p>org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary   </p>
    
    <p>(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Linux 3.10.0-1062.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information) </p>
    
    <p>Command duration or timeout: 16 milliseconds </p>
    
    <p>Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53' System info: host: 'ip-10-160-169-203.syd.non.c1.macquarie.com', ip: '10.160.169.203', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1062.el7.x86_64', java.version: '1.8.0_181'</p>
    
    <p>Driver info: driver.version: unknown Command duration or timeout: 523 milliseconds</p>
  </blockquote>
  
  <p>As I navigate back to the node server, this is the message displayed.</p>
  
  <blockquote>
    <p>22:44:05.604 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)</p>
    
    <p>Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 3459</p>
    
    <p>Only local connections are allowed.</p>
    
    <p>Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.</p>
    
    <p>[1567550645.675][SEVERE]: bind() failed: Cannot assign requested address (99)</p>
    
    <p>22:44:05.988 INFO [ActiveSessionFactory.apply] - Capabilities are: {
      "browserName": "chrome",
      "goog:chromeOptions": {
        "args": [
          "--verbose",
          "--headless",
          "--disable-web-security",
          "--ignore-certificate-errors",
          "--allow-running-insecure-content",
          "--allow-insecure-localhost",
          "--no-sandbox",
          "--port:4040",
          "--disable-gpu"
        ],
        "extensions": [
        ]
      },
      "platform": "LINUX",
      "version": ""
    }</p>
  </blockquote>
  
  <p>I understand the error occurs because within our company, only certain ports were available, and the ChromeDriver is started on random port every time. In order to specify the port this ChromeDriver starts on every time, I tried all kinds of specification for my ChromeOptions and RemoteWebDriver in the Java code, but in vain. </p>
  
  <p>Did anyone else encounter this issue too? If so could you please give me advice on what to do? Or more broadly, is this the correct way of starting the selenium server on EC2?
  Any help will be highly appreciated!</p>