Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BrowserMobProxy Not working inside selenium Grid on docker

See original GitHub issue

I can able to run and get Response Header Using browsermob and selenium using following code

DesiredCapabilities capabilities = new DesiredCapabilities();
        BrowserMobProxy proxy = getProxyServer(); //getting browsermob proxy
        Proxy seleniumProxy = getSeleniumProxy(proxy);
        capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
        capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        WebDriver driver = new ChromeDriver(capabilities);
        proxy.newHar(); // creating new HAR
         List<HarEntry> entries = proxy.getHar().getLog().getEntries();
        for (HarEntry entry : entries) {
    public Proxy getSeleniumProxy(BrowserMobProxy proxyServer) {
        Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxyServer);
        try {
            String hostIp = Inet4Address.getLocalHost().getHostAddress();
            seleniumProxy.setHttpProxy(hostIp + ":" + proxyServer.getPort());
            seleniumProxy.setSslProxy(hostIp + ":" + proxyServer.getPort());
        } catch (UnknownHostException e) {
  "invalid Host Address");
        return seleniumProxy;
    public BrowserMobProxy getProxyServer() {
        BrowserMobProxy proxy = new BrowserMobProxyServer();
        return proxy;

But I am getting problem when i am running it to the selenium docker container

By using this code i can able to open chromebrowser

DesiredCapabilities capabilities =new DesiredCapabilities();
        BrowserMobProxy proxy = getProxyServer(); //getting browsermob proxy
        Proxy seleniumProxy = getSeleniumProxy(proxy);
        capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
        driver = new RemoteWebDriver(new URL(""), capabilities);
        proxy.setHarCaptureTypes(CaptureType.REQUEST_HEADERS, CaptureType.RESPONSE_HEADERS);


But its shows

No internet There is something wrong with the proxy server, or the address is incorrect.

Can anyone know how to run this inside selenium docker container.Thanks advance for your help.


Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

hazmeistercommented, Feb 27, 2019

Browsermobproxy is from a time before docker containers. If you run your browser in the container, and the proxy outside it, you will need to make a small change to your code, using either host.docker.internal or gateway.docker.internal

String proxyHost = "host.docker.internal";
String proxyString = proxyHost + ":" + browserMobProxy.getPort();
proxy = new Proxy();
sreethalcommented, Jan 8, 2021

I tried with host.docker.internal in my python code …But it’s not working. Can you please explain how to implement the browsermobproxy in python with selenium grid. The code to start browsermobproxy server and client is running on my chrome node. is this the correct way?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running browsermob with selenium grid on docker
To Answer my own question based on the response from Sergey: I pushed a browsermob-proxy image to docker hub: ...
Read more >
Browsermob proxy how to make it work with selenium grid ...
PROXY, seleniumProxy);. The problem is running on local its fine but running it on grid(either own or browserstack) it is not working.
Read more >
How to Setup Selenium Grid with BrowserMob-Proxy to pass ...
Create docker-compose to run Selenium Grid ... Selenium provide proxy implementation but that does not provide request manipulation.
Read more >
How To Use On The Remote Server From Docker - ADocLib
If you're running BrowserMob Proxy within a Java application or Selenium ... The problem is running on local its fine but running it...
Read more >
Gridlastic Connect
Note: if you are using Docker Desktop see our Docker containers ... Starting a tunnel does not affect your selenium grid nodes capability...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found