Error while proxying request kubectl proxy

12/16/2020

I'm trying to follow this documentation https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/.

After running this command

kubectl proxy --port=8080 &

I get the output

Starting to serve on 127.0.0.1:8080

However when I run "curl http://localhost:8080/api/" to hit the server, I get this response

dial tcp: lookup localhost: no such host

Any idea's why I would get this response?

EDIT: I'm using a VPN to connect to corporate network. When I disable the VPN I still get the same message for both localhost and 127.0.0.1 (same exact message for both).

I'm not using kubeadm.

When I run host localhost I get this output

localhost has address 127.0.0.1
localhost has IPv6 address ::1

cat /etc/hosts

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
-- cWerning
kubectl
kubernetes

1 Answer

12/17/2020

It is possible you might have http_proxy set on you system , so try curl with noproxy as following :

curl --noproxy '*' http://localhost:8080

If you want to check if the http_proxy is set :

echo $http_proxy

-- confused genius
Source: StackOverflow