"http: invalid Host header" error while executing a command in Pod

Cluster information:

Kubernetes version: 1.27.3
Cloud being used: bare-metal
Installation method: via kubeadm --config …
Host OS: Ubuntu 20.04.6 LTS (Master Node)
CNI and version: flannel 0.22.0
CRI and version: cri-dockerd 0.3.4

I’ve launched my K8s cluster and applied some test deployments (nginx).
All pods work fine, and all pods and services are accessible.


But I can’t execute commands in Pod`s containers via kubectl exec:

kubectl exec -it nginx-deployment-74b6b979f-9rpmv -- bash

The result:

error: An internal error occurred: error executing command in container: http: invalid Host header

If I have created another working node - result will be the same.
If I try to execute a command by docker docker exec -it ... - it works fine.
I suggested that the problem may lie at the cri-dockerd or cgroupdriver, but I’ve checked all those settings: I use cri-docker and I set systemd as cgroup driver both in the Kubelet and the Docker daemon.
I’m glad to get some helpful tips for debugging this tricky and annoying problem.

1 Like

Solved :v:
The root of the problem is the known Golang 1.20.6 Issue which I’ve used for building cri-dockerd.

Using Go v1.20.5 instead of v.1.20.6 is the solution for me.

I had to totally remove the Cri-Docker service from the host and rebuild/reinstall it again.

1 Like