# Got "Unauthorized" when accessing an authorized cluster endpoint

**URL:** <https://forums.suse.com/t/got-unauthorized-when-accessing-an-authorized-cluster-endpoint/39164>\
**Category:** SUSE Rancher Prime\
**Created:** [October 6, 2022, 9:32pm UTC](https://forums.suse.com/t/got-unauthorized-when-accessing-an-authorized-cluster-endpoint/39164 "2022-10-06T21:32:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sang\_Nguyen](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sang_nguyen/32/9508_2.png) [@Sang\_Nguyen](https://forums.suse.com/u/Sang_Nguyen)\
**Post date:** [October 6, 2022, 9:32pm UTC](https://forums.suse.com/t/got-unauthorized-when-accessing-an-authorized-cluster-endpoint/39164/1 "2022-10-06T21:32:22Z")

</div>

Rancher Server: v2.6.8  
Kubernetes Cluster: RKE2  
Version: v1.24.4+rke2r1

Hi there, I have created a RKE2 cluster via Rancher Server. I downloaded the kubeconfig file from Rancher UI, and I was trying to access the cluster with kubectl and kubeconfig. I was able to access the cluster via Rancher Server’s context. However, if I access that cluster directly using:

```auto
kubectl --kubeconfig /custom/path/kube.config --context <CLUSTER_NAME>-<NODE_NAME> get pods

```

as describe here: [Access a Cluster with Kubectl and kubeconfig | Rancher Manager](https://docs.ranchermanager.rancher.io/how-to-guides/advanced-user-guides/manage-clusters/access-clusters/use-kubectl-and-kubeconfig#connecting-directly-to-clusters-without-fqdn-defined)

I got an error “error: You must be logged in to the server (Unauthorized)”

Is there anyone know the reason why? And how to fix it?

Thanks!

---

<div class="post-metadata">

**Author:** ![Sang\_Nguyen](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sang_nguyen/32/9508_2.png) [@Sang\_Nguyen](https://forums.suse.com/u/Sang_Nguyen)\
**Post date:** [October 6, 2022, 9:34pm UTC](https://forums.suse.com/t/got-unauthorized-when-accessing-an-authorized-cluster-endpoint/39164/2 "2022-10-06T21:34:24Z")

</div>

Look like the user inside that kubeconfig does not have an access privilege to connect that cluster…

---

<div class="post-metadata">

**Author:** ![bear454](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/bear454/32/9125_2.png) [@bear454](https://forums.suse.com/u/bear454)\
**Post date:** [October 7, 2022, 5:01pm UTC](https://forums.suse.com/t/got-unauthorized-when-accessing-an-authorized-cluster-endpoint/39164/3 "2022-10-07T17:01:57Z")

</div>

Hi @Sang_Nguyen , this doesn’t appear to be a cluster setup via _Rancher Setup_ (as defined in the sticky post). I’ll move your post to the appropriate topic.

---

<div class="post-metadata">

**Author:** ![lgao](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/lgao/32/7058_2.png) [@lgao](https://forums.suse.com/u/lgao)\
**Post date:** [August 22, 2023, 3:27pm UTC](https://forums.suse.com/t/got-unauthorized-when-accessing-an-authorized-cluster-endpoint/39164/4 "2023-08-22T15:27:15Z")

</div>

I do have de same problem, able to access cluster via rancher api but not work via local endpoint(master api), any idea?  
rke2 1.24.9, provisioned by rancher.

---

<div class="post-metadata">

**Author:** ![vaishnav](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vaishnav/32/10688_2.png) [@vaishnav](https://forums.suse.com/u/vaishnav)\
**Post date:** [November 17, 2023, 5:22am UTC](https://forums.suse.com/t/got-unauthorized-when-accessing-an-authorized-cluster-endpoint/39164/5 "2023-11-17T05:22:29Z")

</div>

I was able to resolve this issue by restarting the rancher deployment. This is a known [issue](https://github.com/rancher/rancher/issues/42255).
