Internal error occurred: error executing command in container: http: invalid Host header

Hi,

I received following error when executed kubectl exec -it -c – /bin/bash command:

Error: Internal error occurred: error executing command in container: http: invalid Host header

Currently, created Kubernetes environment on Minikube. Following are the details when executed kubectl describe command:
Name: testpod
Namespace: default
Priority: 0
Service Account: default
Node: ip-172-31-10-146/172.31.10.146
Start Time: Wed, 02 Aug 2023 07:35:01 +0000
Labels:
Annotations:
Status: Running
IP: 10.244.0.87
IPs:
IP: 10.244.0.87
Containers:
c00:
Container ID: docker://d8d23e1655ac7903baf7715516ae42981079a7288fad4dbad33bcce954168cc6
Image: ubuntu
Image ID: docker-pullable://ubuntu@sha256:0bced47fffa3361afa981854fcabcd4577cd43cebbb808cea2b1f33a3dd7f508
Port:
Host Port:
Command:
/bin/bash
-c
while true; do echo Hello-Bhupinder; sleep 5 ; done
State: Running
Started: Wed, 02 Aug 2023 07:35:03 +0000
Ready: True
Restart Count: 0
Environment:
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-tzb4d (ro)
c01:
Container ID: docker://85a6433de5a01861a660372114efd11fe646a997a0f073d149485d3cd4e5d431
Image: httpd
Image ID: docker-pullable://httpd@sha256:d7262c0f29a26349d6af45199b2770d499c74d45cee5c47995a1ebb336093088
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Wed, 02 Aug 2023 07:35:05 +0000
Ready: True
Restart Count: 0
Environment:
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-tzb4d (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-tzb4d:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional:
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors:
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message


Normal Scheduled 14s default-scheduler Successfully assigned default/testpod to ip-172-31-10-146
Normal Pulling 13s kubelet Pulling image “ubuntu”
Normal Pulled 12s kubelet Successfully pulled image “ubuntu” in 1.415433206s (1.415461286s including waiting)
Normal Created 12s kubelet Created container c00
Normal Started 12s kubelet Started container c00
Normal Pulling 12s kubelet Pulling image “httpd”
Normal Pulled 10s kubelet Successfully pulled image “httpd” in 1.472691548s (1.472706988s including waiting)
Normal Created 10s kubelet Created container c01
Normal Started 10s kubelet Started container c01

I would really appreciate if any one can help in solving said error.

Hi @amrit07nara ,
Please run the command correctly. This is an incomplete command.

kubectl exec -it <pod-name> -c <container-name> -- /bin/bash
``
Regards,

Thanks for your response but showing same result.
OP:
root@ip-172-31-10-146:/home/ubuntu# kubectl exec -it testpod -c c00 – /bin/bash
error: Internal error occurred: error executing command in container: http: invalid Host header

It looks like an issue within your container. Please debug it. If you are created a custom image from Dockerfile. Look at that also.

any step would you suggest for debugging container?