Kubectl unable to connect to any cluster, using curl works

Cluster information:

Kubernetes version: 1.21
Cloud being used: AWS EKS, Linode LKS

I am running Arch Linux on my local machine with the latest kubectl binary. I have also tried AWS provided binary. The same kubeconfig does work on my macbook pro and on my windows box with WSL2 without issues.

I am not able to connect to any cluster (that I tried with) by using kubectl. However I have verified that I am able to access the API endpoints listed in the kubeconfig by using cURL and providing the authorization token in the headers.

❯ kubectl --kubeconfig ~/test-kubeconfig.yaml get nodes
The connection to the server <my-cluster-api-endpoint> was refused - did you specify the right host or port?

The same error happens when I try AWS EKS endpoints or Linode LKS endpoints. I am able to fetch the authorization token with the aws cli tool and use that to get a list of my nodes with cURL.

> aws eks get-token --region <my-region> --cluster <my-cluster>
> url --insecure https://<my-cluster-api-endpoint>/api/v1/nodes -H "Authorization: Bearer <token-from-previous-command>"
<prints correct information about the nodes in the cluster>

I have tried the following command I found from another thread:

sudo swapoff -a
strace -eopenat kubectl get nodes

But that did not result in a success either.

I am unsure how to proceed further with this. I am also not sure what other information I should be providing.

I got it to work by first completely removing kubectl and then installing kubernetes-tools that comes with kubectl (essentially reinstalled kubectl this way).