# Docker Container: Could not connect to the playwright process at port

**URL:** <https://forum.robotframework.org/t/docker-container-could-not-connect-to-the-playwright-process-at-port/4870>\
**Category:** Browser\
**Created:** [26 October 2022 15:14 UTC](https://forum.robotframework.org/t/docker-container-could-not-connect-to-the-playwright-process-at-port/4870 "2022-10-26T15:14:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![terry.jp](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@terry.jp](https://forum.robotframework.org/u/terry.jp)\
**Post date:** [26 October 2022 15:14 UTC](https://forum.robotframework.org/t/docker-container-could-not-connect-to-the-playwright-process-at-port/4870/1 "2022-10-26T15:14:50Z")

</div>

Whilst running tests using pabot in a Docker container whilst extending Browser library with a JavaScript module some failures occur due to not being able to connect to playwright process. See stack trace at the bottom.

Docker base image is marketsquare/robotframework-browser image.

Some tests do pass however this pass rate varies with each run. Pabot processes is set to 5. Chromium browser running headless.

No issues experienced when running locally with same setup and commands from IDE.

Any ideas as to what could cause this?

line 2: Initializing library ‘Browser’ with arguments [jsextension=/home/pwuser/.local/lib/python3.8/site-packages/_ **/keywords/** _.js] failed: Could not connect to the playwright process at port 54121.  
Traceback (most recent call last):  
File “/home/pwuser/.local/lib/python3.8/site-packages/Browser/browser.py”, line 745, in **init**  
libraries.append(self.\_initialize\_jsextension(jsextension))  
File “/home/pwuser/.local/lib/python3.8/site-packages/Browser/browser.py”, line 779, in \_initialize\_jsextension  
with self.playwright.grpc\_channel() as stub:  
File “/usr/lib/python3.8/contextlib.py”, line 113, in **enter**  
return next(self.gen)  
File “/home/pwuser/.local/lib/python3.8/site-packages/Browser/playwright.py”, line 139, in grpc\_channel  
playwright\_process = self.\_playwright\_process  
File “/usr/lib/python3.8/functools.py”, line 967, in **get**  
val = self.func(instance)  
File “/home/pwuser/.local/lib/python3.8/site-packages/Browser/playwright.py”, line 57, in \_playwright\_process  
self.wait\_until\_server\_up()  
File “/home/pwuser/.local/lib/python3.8/site-packages/Browser/playwright.py”, line 125, in wait\_until\_server\_up  
raise RuntimeError(  
RuntimeError: Could not connect to the playwright process at port 54121.

---

<div class="post-metadata">

**Author:** ![aaltat](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/aaltat/32/15_2.png) [@aaltat](https://forum.robotframework.org/u/aaltat)\
**Post date:** [27 October 2022 18:18 UTC](https://forum.robotframework.org/t/docker-container-could-not-connect-to-the-playwright-process-at-port/4870/2 "2022-10-27T18:18:33Z")

</div>

We sometimes see this same problem in our CI environment too. Current we don’t have good solution for it, because root cause is unknown for us. If you can dig any information out from your system. Like is process actually running, is there something in the nix logs or something similar we would be greatly interested. Perhaps we can find something to solve the problem

---

<div class="post-metadata">

**Author:** ![terry.jp](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@terry.jp](https://forum.robotframework.org/u/terry.jp)\
**Post date:** [23 May 2023 09:39 UTC](https://forum.robotframework.org/t/docker-container-could-not-connect-to-the-playwright-process-at-port/4870/3 "2023-05-23T09:39:23Z")

</div>

@aaltat At long last, after the issue creeping up now and again over several months, I have been able to get a workaround that thus far has not thrown the error.

I am currently using marketsquare/robotframework-browser:16.0.2 as my base image in my Dockerfile.

After building the image in our CI pipeline I run the following steps:

- run container with interactive and detached flags (-i -d) to bash shell

_e.g. docker run --rm -i -d --name containerName imageName bash_

- run a new command on the container using docker exec command to start playwright process on a specified port

_e.g. docker exec -i containerNamenode /home/pwuser/.local/lib/python3.8/site-packages/Browser/wrapper/index.js $(playwrightProcessPort) &_

- Execute robot tests which import Browser with optional argument playwright\_process\_port passing as a variable the same port we used to start the playwright process at previous step

_e.g. docker exec -i containerNamenode pabot --pabotlib --testlevelsplit --processes -A argfile -v PlaywrightProcessPort:$(playwrightProcessPort) ./TestSuites_

---

<div class="post-metadata">

**Author:** ![aaltat](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/aaltat/32/15_2.png) [@aaltat](https://forum.robotframework.org/u/aaltat)\
**Post date:** [26 May 2023 21:25 UTC](https://forum.robotframework.org/t/docker-container-could-not-connect-to-the-playwright-process-at-port/4870/4 "2023-05-26T21:25:35Z")

</div>

For us the problem is not that severe anymore, we did not find the root cause but where we able to see that one utest is problematic in Mac, but not in others. So we do not run that test anymore in Mac. Our current assumption is that in our CI, Mac sometimes runs out of resources and just hangs. For Windows or Linux we have not seem similar problems.
