`make run` fails with port 8080 already in in use

An example error

You will see this issue when trying to run the controller with make run in a Shell tab.

root@kubernetes-vm:~/demo# make run
test -s /root/demo/bin/controller-gen || GOBIN=/root/demo/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.2
/root/demo/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
/root/demo/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
go run ./main.go
1.6655869312425723e+09  INFO    controller-runtime.metrics      Metrics server is starting to listen    {"addr": ":8080"}
1.6655869312429175e+09  ERROR   controller-runtime.metrics      metrics server failed to listen. You may want to disable the metrics server or use another port if it is due to conflicts       {"error": "error listening on :8080: listen tcp :8080: bind: address already in use"}
sigs.k8s.io/controller-runtime/pkg/metrics.NewListener
        /root/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.2/pkg/metrics/listener.go:48
sigs.k8s.io/controller-runtime/pkg/manager.New
        /root/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.2/pkg/manager/manager.go:373
main.main
        /root/demo/main.go:68
runtime.main
        /usr/local/go/src/runtime/proc.go:250
1.6655869312430358e+09  ERROR   setup   unable to start manager {"error": "error listening on :8080: listen tcp :8080: bind: address already in use"}
main.main
        /root/demo/main.go:88
runtime.main
        /usr/local/go/src/runtime/proc.go:250
exit status 1
make: *** [Makefile:69: run] Error 1

Fixing the issue

This is likely caused by running make run in both Shell tabs. You can check the other tab and ctrl+c the running controller.

If this either does not work, or you just want a faster fix, you can kill the use of port 8080 with fuser -k 8080/tcp in your affected Shell tab.

Last updated