---
title: 执行kubectl get nodes时提示The connection to the server localhost的解决方法
description: "执行kubectl get nodes时，提示“The connection to the server localhost:8080 was refused”。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengcpfs/troubleshooting/trouble/kunpengdockerk8s_09_0004.html
sourcePath: /source/zh/kunpengcpfs/troubleshooting/trouble/kunpengdockerk8s_09_0004.html
indexId: 0b485edf8e03220ea4e0e1c356b3ab998cb8a172c3950ac12bf5d9aef649afe376
---
# 执行kubectl get nodes时提示The connection to the server localhost的解决方法

#### 问题现象描述

执行kubectl get nodes时，提示“The connection to the server localhost:8080 was refused”。


#### 关键过程、根本原因分析

Kube的config文件并没有赋予合理所属权导致执行权限不够。


#### 结论、解决方案及效果

1. 依次执行以下命令重新赋予合理所属权。

```
cp /etc/kubernetes/admin.conf $HOME/
chown $(id -u):$(id -g) $HOME/admin.conf
```


2. 执行如下命令更新环境变量。

```
export KUBECONFIG=$HOME/admin.conf
```


3. 重新执行kubectl get nodes查看节点。

```
kubectl get nodes
```
