Skip to content

[🐛 Bug]: Unable to create session, bind address port already in use  #14257

@nidhintleo

Description

@nidhintleo

What happened?

I have a test automation setup with selenium in k8s version v1.28.3 and Have a Selenium hub(selenium/hub:4.20.0-20240425) , selenium node (selenium/node-docker:4.20.0-20240425) and when a test the hub send request to selenium node to spin up a browser container (selenium/standalone-chrome:4.20.0-20240425) by communicating with the docker daemon by using the config.toml file of selenium node.

i have already tried with new version of chrome image (126) but the issue is still there.

the tests will work smoothly but my issue is some times i got below error for random test cases

message": "Could not start a new session. Could not start a new session. Unable to start container: 1f3a8280424b0d3e23216b0d3be9059732ee5e7f096b04439611694099cbf9bc\ndriver failed programming external connectivity on endpoint optimistic_curie (89fffaa21818af9547dcae3b2b2e822769b5efcc02ead9008c9084821600acb1): failed to bind port 0.0.0.0:7946\u002ftcp: Error starting userland proxy: listen tcp4 0.0.0.0:7946: bind: address already in use \nHost info: host: 'node-docker1-6d6f5dc48-kgps7', ip: '10.233.125.187'\nBuild info: version: '4.20.0', revision: '866c76ca80'\nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-113-generic', java.version: '17.0.11'\nDriver info: driver.version: unknown\nBuild info: version: '4.20.0', revision: '866c76ca80'\nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-113-generic', java.version: '17.0.11'\nDriver info: driver.version: unknown"

the docker version is 27.0.3

in my knowledge the docker will pick a random free port to avoid conflicts then why its not picking the used port.?
and how to fix this issue.?

How can we reproduce the issue?

its a random one.

Relevant log output

message": "Could not start a new session. Could not start a new session. Unable to start container: 1f3a8280424b0d3e23216b0d3be9059732ee5e7f096b04439611694099cbf9bc\ndriver failed programming external connectivity on endpoint optimistic_curie (89fffaa21818af9547dcae3b2b2e822769b5efcc02ead9008c9084821600acb1): failed to bind port 0.0.0.0:7946\u002ftcp: Error starting userland proxy: listen tcp4 0.0.0.0:7946: bind: address already in use \nHost info: host: 'node-docker1-6d6f5dc48-kgps7', ip: '10.233.125.187'\nBuild info: version: '4.20.0', revision: '866c76ca80'\nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-113-generic', java.version: '17.0.11'\nDriver info: driver.version: unknown\nBuild info: version: '4.20.0', revision: '866c76ca80'\nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-113-generic', java.version: '17.0.11'\nDriver info: driver.version: unknown"



value": {
        "error": "session not created",
        "message": "Could not start a new session. Could not start a new session. Unable to start container: db56c562e290492599c884dcb0443f28f8e213578e50a8fde87e00945ae786cb\ndriver failed programming external connectivity on endpoint elated_benz (edae185be76790c42c3de5e636bec418c1361f39ff75dbdef04ee9fd79946d4f): Bind for 0.0.0.0:3298 failed: port is already allocated \nHost info: host: 'node-docker3-8476bcd446-z4xz6', ip: '10.233.77.161'\nBuild info: version: '4.20.0', revision: '866c76ca80'\nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-113-generic', java.version: '17.0.11'\nDriver info: driver.version: unknown\nBuild info: version: '4.20.0', revision: '866c76ca80'\nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-113-generic', java.version: '17.0.11'\nDriver info: driver.version: unknown",

    WebDriverError: Unable to parse new session response: {
      "value": {
        "error": "session not created",
        "message": "Could not start a new session. Could not start a new session. Unable to start container: 709f167ac42990ba4468684b3d1db7ed7ff649bf6576b739b09b15009317b770\ndriver failed programming external connectivity on endpoint charming_heyrovsky (ee817b360fd656b590841380664f0a536f1f5943b289c556eaeaeb3d4c6b9f0c): Bind for 0.0.0.0:13620 failed: port is already allocated \nHost info: host: 'node-docker1-6d6f5dc48-kgps7', ip: '10.233.125.187'\nBuild info: version: '4.20.0', revision: '866c76ca80'\nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-113-generic', java.version: '17.0.11'\nDriver info: driver.version: unknown\nBuild info: version: '4.20.0', revision: '866c76ca80'\nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-113-generic', java.version: '17.0.11'\nDriver info: driver.version: unknown"

Operating System

Ubuntu 22.04

Selenium version

4.20

What are the browser(s) and version(s) where you see this issue?

selenium/standalone-chrome:4.20.0-20240425

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 124.0.6367.78, Google Chrome 124.0.6367.78

Are you using Selenium Grid?

selenium/hub:4.20.0-20240425

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!I-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions