Selenium with kubernetes - unable to access from outside


I try to install selenium hub with kubernetes on linux machine.
I take the files from the example
Below is describe of what I got .

I am able to access the hub using localhost/ but I can’t access it using the ip of machine .

I also run the commands :
kubectl port-forward $PODNAME 4444:4444
nohup kubectl proxy --address=‘’ --disable-filter=true &

What is missing ?

[qa@qaomgutil5m root]$ kubectl describe service/selenium-hub
Name: selenium-hub
Namespace: default
Labels: app=selenium-hub
Selector: app=selenium-hub
Type: NodePort
IP Family Policy: SingleStack
IP Families: IPv4
External IPs:
Port: port0 4444/TCP
TargetPort: 4444/TCP
NodePort: port0 31648/TCP
Session Affinity: None
External Traffic Policy: Cluster

describe deployment.apps/selenium-hub
Name: selenium-hub
Namespace: default
CreationTimestamp: Sun, 25 Jul 2021 11:22:10 +0000
Labels: app=selenium-hub
Annotations: 1
Selector: app=selenium-hub
Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app=selenium-hub
Image: selenium/hub:3.141
Port: 4444/TCP
Host Port: 0/TCP
cpu: 500m
memory: 1000Mi
Liveness: http-get http://:4444/wd/hub/status delay=30s timeout=5s period=10s #success=1 #failure=3
Readiness: http-get http://:4444/wd/hub/status delay=30s timeout=5s period=10s #success=1 #failure=3
Type Status Reason

Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
NewReplicaSet: selenium-hub-6dd87dfcb6 (1/1 replicas created)

Is the selenium application in the pod only listening on the localhost interface perhaps? Install net tools inside the container and run netstat -plnt if you’re not sure, to see what interfaces are being listened over.

The port-forward is the correct way to proxy to the pod. You can do it by pod/${PODNAME} or by the service svc/${SERVICE_NAME}.

The netstat should be in under the kubernetes docker?
How do I install it there ?

Needs to be done in the container running selenium.

Open a shell into the container

kubectl exec -it ${PODNAME} -- sh

Installing it depends on what the container is built from. It’s going to be one of these commands:

Alpine based images:

apk add -U net-tools

RHEL based images (if dnf doesn’t work, use yum instead):

dnf install net-tools

Debian based images, the first command updates the cache and 2nd installs:

apt update
apt install net-tools

The net-tools package comes with the netstat command.

Now when you run netstat -plnt, what you’re looking for is something like in the Local Address column to know it’s listening on all interfaces.

Though I’m guessing you’re using some stock image for your pod. Can you share the manifest for your deployment?

Thanks for your reply
I got error install the netstat

[qa@qaomgutil5m /]$ kubectl exec -it selenium-hub-6dd87dfcb6-5sxxm – sh
$ apt install
Reading package lists… Done
Building dependency tree
Reading state information… Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ apt install net-tools
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package net-tools


This is the file I use :
apiVersion: apps/v1
kind: Deployment
name: selenium-hub
app: selenium-hub
replicas: 1
app: selenium-hub
app: selenium-hub
- name: selenium-hub
image: selenium/hub:3.141
- containerPort: 4444
memory: “1000Mi”
cpu: “.5”
path: /wd/hub/status
port: 4444
initialDelaySeconds: 30
timeoutSeconds: 5
path: /wd/hub/status
port: 4444
initialDelaySeconds: 30
timeoutSeconds: 5

This container doesn’t run as root, I didn’t expect that… lol

Also for the future, some things to know:

  • You missed apt update, which is necessary in a lot of these containers because the cache is typically removed on build.
  • When sharing YAML and terminal output, use code blocks to preserve formatting.

Anyways, I pulled down the image and checked it out. It seems fine. This shows you exactly what I did and what I saw.

[protosam@nullhost]$ docker run --name selenium -d -u 0:0 selenium/hub:3.141 

[protosam@nullhost]$ docker exec -it selenium bash

root@03e642e3ba29:/# apt update && apt install net-tools
Get:1 focal-security InRelease [114 kB]
Get:2 focal InRelease [265 kB]                       
Get:3 focal-security/universe amd64 Packages [784 kB]
Get:4 focal-updates InRelease [114 kB]
Get:5 focal/main amd64 Packages [1275 kB]
Get:6 focal-security/main amd64 Packages [986 kB]
Get:7 focal/universe amd64 Packages [11.3 MB]
Get:8 focal-updates/main amd64 Packages [1417 kB]   
Get:9 focal-updates/universe amd64 Packages [1055 kB]
Fetched 17.4 MB in 3s (5900 kB/s)                     
Reading package lists... Done
Building dependency tree       
Reading state information... Done
33 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 33 not upgraded.
Need to get 196 kB of archives.
After this operation, 864 kB of additional disk space will be used.
Get:1 focal/main amd64 net-tools amd64 1.60+git20180626.aebd88e-1ubuntu1 [196 kB]
Fetched 196 kB in 1s (262 kB/s)  
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package net-tools.
(Reading database ... 8594 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20180626.aebd88e-1ubuntu1_amd64.deb ...
Unpacking net-tools (1.60+git20180626.aebd88e-1ubuntu1) ...
Setting up net-tools (1.60+git20180626.aebd88e-1ubuntu1) ...

root@03e642e3ba29:/# netstat -plnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0  *               LISTEN      14/java             

root@03e642e3ba29:/# exit

[protosam@nullhost]$ docker kill selenium 

[protosam@nullhost]$ docker rm selenium

The application also seems responsive when with your manifest over port-forward.

[protosam@nullhost]$ kubectl get pods -l app=selenium-hub
NAME                            READY   STATUS    RESTARTS   AGE
selenium-hub-6dd87dfcb6-4snff   0/1     Running   0          21s

[protosam@nullhost]$ kubectl get pods -l app=selenium-hub -oname

[protosam@nullhost]$ kubectl port-forward $(kubectl get pods -l app=selenium-hub -oname) 4444:4444
Forwarding from -> 4444
Forwarding from [::1]:4444 -> 4444
Handling connection for 4444
... I left this running and did the next step in another terminal...

[protosam@nullhost]$ curl -w'\n' -i localhost:4444/wd/hub/status
HTTP/1.1 200 OK
Date: Mon, 26 Jul 2021 15:57:46 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 364
Server: Jetty(9.4.z-SNAPSHOT)

  "status": 0,
  "value": {
    "ready": false,
    "message": "No spare hub capacity",
    "build": {
      "revision": "e82be7d358",
      "time": "2018-11-14T08:25:53",
      "version": "3.141.59"
    "os": {
      "arch": "amd64",
      "name": "Linux",
      "version": "5.10.25-linuxkit"
    "java": {
      "version": "1.8.0_292"


with localhost it is working
The problem is when I try to access it from outside or even with the ip/hostname of the machine from inside the machine

I got connection refused error

Do you what should be done to be able to access the selenium from outside ?

AFter running the command :
minikube service --url selenium-hub

I can access the selenium hub from within the machine using command :curl but I can’t access the selenium-hub from outside like I can access the minikube dashboard from outside