The installation script shows "Unable to connect to the server: Forbidden” | kubectl commands, in general, are failing with “Forbidden”

Modified on Fri, 17 Nov 2023 at 02:15 PM

Usually, the “forbidden” response means a communication issue between the kubectl and Kubernetes API. There are two possibilities:

Kubectl is not configured:

  • Verify if the /etc/kubernetes/admin.conf file is present
  • Copy it to the default configuration location:

sudo su # Login as root user

mkdir -p /root/.kube # Default kubectl configuration directory
cp -i /etc/kubernetes/admin.conf /root/.kube/config # Copy the config file created by the installation script
export KUBECONFIG="" # Removes possible config file path override

Proxy issues. After testing the following configurations, make sure to make them permanent by using your favorite method to manage environment properties:

  • Identify your Kubernetes cluster IP:

$ cat /etc/kubernetes/admin.conf
- cluster:    
    certificate-authority-data: LS0tLS1CRUdJTi(...)
  name: kubernetes
  • Include the server IP and its subnets in the no_proxy and NO_PROXY variables:

sudo su
export no_proxy=$no_proxy,,

  • As an alternative to the no_proxy option, remove all the proxy configurations:

export http_proxy=""
export https_proxy=""
export HTTP_PROXY=""
export HTTPS_PROXY=""

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article