# The connection to the server 192.168.1.2:6443 was refused - did you specify the right host or port?

**URL:** <https://discuss.kubernetes.io/t/the-connection-to-the-server-192-168-1-2-6443-was-refused-did-you-specify-the-right-host-or-port/22260>\
**Category:** General Discussions\
**Created:** [December 10, 2022, 6:37pm UTC](https://discuss.kubernetes.io/t/the-connection-to-the-server-192-168-1-2-6443-was-refused-did-you-specify-the-right-host-or-port/22260 "2022-12-10T18:37:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bestman](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@bestman](https://discuss.kubernetes.io/u/bestman)\
**Post date:** [December 10, 2022, 6:37pm UTC](https://discuss.kubernetes.io/t/the-connection-to-the-server-192-168-1-2-6443-was-refused-did-you-specify-the-right-host-or-port/22260/1 "2022-12-10T18:37:03Z")

</div>

I am trying to install and run Kubernetes on my Ubuntu 22.04LTS machine. I followed the installation link I specified below, but I get the following errors when I try `kubectl get pods` or `kubectl get nodes` for example:

```auto

E1210 10:35:25.649853 16219 memcache.go:238] couldn't get current server API group list: Get "https://192.168.1.2:6443/api?timeout=32s": dial tcp 192.168.1.2:6443: connect: connection refused
E1210 10:35:25.650138 16219 memcache.go:238] couldn't get current server API group list: Get "https://192.168.1.2:6443/api?timeout=32s": dial tcp 192.168.1.2:6443: connect: connection refused
E1210 10:35:25.651789 16219 memcache.go:238] couldn't get current server API group list: Get "https://192.168.1.2:6443/api?timeout=32s": dial tcp 192.168.1.2:6443: connect: connection refused
E1210 10:35:25.653224 16219 memcache.go:238] couldn't get current server API group list: Get "https://192.168.1.2:6443/api?timeout=32s": dial tcp 192.168.1.2:6443: connect: connection refused
E1210 10:35:25.654932 16219 memcache.go:238] couldn't get current server API group list: Get "https://192.168.1.2:6443/api?timeout=32s": dial tcp 192.168.1.2:6443: connect: connection refused
The connection to the server 192.168.1.2:6443 was refused - did you specify the right host or port?

```

### Cluster information:

Kubernetes version:  
`kubeadm version: &version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.0", GitCommit:"b46a3f887ca979b1a5d14fd39cb1af43e7e5d12d", GitTreeState:"clean", BuildDate:"2022-12-08T19:57:06Z", GoVersion:"go1.19.4", Compiler:"gc", Platform:"linux/amd64"}`

Cloud being used:` localhost`

Installation method: [Installing kubeadm | Kubernetes](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/)

Host OS:

```auto
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy

```

CNI and version:  
CRI and version:

This is `/.kube/config` file:

```auto
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakN>
    server: https://192.168.1.2:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQW>
    client-key-data: LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFb2dJQkFBS0>

```

This is `/etc/containerd/config.toml` file:

```auto

[plugins]
  [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]

  [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
      SystemdCgroup = true

  [plugins."io.containerd.grpc.v1.cri"]
  sandbox_image = "registry.k8s.io/pause:3.2"

```

When I try `systemctl status kubelet`, I get the following result:

● kubelet.service - kubelet: The Kubernetes Node Agent  
Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)  
Drop-In: /etc/systemd/system/kubelet.service.d  
└─10-kubeadm.conf  
Active: activating (auto-restart) (Result: exit-code) since Sat 2022-12-10 16:46:24 PST; 9s ago  
Docs: [Kubernetes Documentation | Kubernetes](https://kubernetes.io/docs/home/)  
Process: 6420 ExecStart=/usr/bin/kubelet $KUBELET\_KUBECONFIG\_ARGS $KUBELET\_CONFIG\_ARGS $KUBELET\_KUBEADM\_ARGS $KUBELET\_EXTRA\_ARGS (code=exited, status=1/FAILURE)  
Main PID: 6420 (code=exited, status=1/FAILURE)  
CPU: 103ms

And the content of `/etc/systemd/system/kubelet.service.d/10-kubeadm.conf`:

```auto

  GNU nano 6.2 /etc/systemd/system/kubelet.service.d/10-kubeadm.conf                                                    
# Note: This dropin only works with kubeadm and kubelet v1.11+
[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
# This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
EnvironmentFile=-/etc/default/kubelet
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS

```

This is the result for `journalctl -u kubelet` command:

```auto

Dec 06 22:14:42 a systemd[1]: Started kubelet: The Kubernetes Node Agent.
Dec 06 22:14:43 a kubelet[85576]: I1206 22:14:43.254559 85576 server.go:413] "Kubelet version" kubeletVersion="v1.25.4"
Dec 06 22:14:43 a kubelet[85576]: I1206 22:14:43.254699 85576 server.go:415] "Golang settings" GOGC="" GOMAXPROCS="" GOTRACEBACK=""
Dec 06 22:14:43 a kubelet[85576]: I1206 22:14:43.255385 85576 server.go:576] "Standalone mode, no API client"
Dec 06 22:14:43 a kubelet[85576]: I1206 22:14:43.295733 85576 server.go:464] "No api server defined - no events will be sent to API server"
Dec 06 22:14:43 a kubelet[85576]: I1206 22:14:43.295813 85576 server.go:660] "--cgroups-per-qos enabled, but --cgroup-root was not specified. defaulting to /"
Dec 06 22:14:43 a kubelet[85576]: E1206 22:14:43.296299 85576 run.go:74] "command failed" err="failed to run Kubelet: running with swap on is not supported, please disable swap! or set --f>
Dec 06 22:14:43 a systemd[1]: kubelet.service: Current command vanished from the unit file, execution of the command list won't be resumed.
Dec 06 22:14:43 a systemd[1]: kubelet.service: Main process exited, code=exited, status=1/FAILURE
Dec 06 22:14:43 a systemd[1]: kubelet.service: Failed with result 'exit-code'.
Dec 06 22:14:43 a systemd[1]: Stopped kubelet: The Kubernetes Node Agent.
Dec 06 22:14:43 a systemd[1]: Started kubelet: The Kubernetes Node Agent.
Dec 06 22:14:43 a kubelet[85623]: E1206 22:14:43.688813 85623 run.go:74] "command failed" err="failed to load kubelet config file, error: failed to load Kubelet config file /var/lib/kubele>
Dec 06 22:14:43 a systemd[1]: kubelet.service: Main process exited, code=exited, status=1/FAILURE
Dec 06 22:14:43 a systemd[1]: kubelet.service: Failed with result 'exit-code'.
Dec 06 22:14:53 a systemd[1]: kubelet.service: Scheduled restart job, restart counter is at 1.
Dec 06 22:14:53 a systemd[1]: Stopped kubelet: The Kubernetes Node Agent.
Dec 06 22:14:53 a systemd[1]: Started kubelet: The Kubernetes Node Agent.
Dec 06 22:14:53 a kubelet[85707]: E1206 22:14:53.884675 85707 run.go:74] "command failed" err="failed to load kubelet config file, error: failed to load Kubelet config file /var/lib/kubele>
Dec 06 22:14:53 a systemd[1]: kubelet.service: Main process exited, code=exited, status=1/FAILURE

```

---

<div class="post-metadata">

**Author:** ![Rabah\_DevOps](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/rabah_devops/32/9679_2.png) [@Rabah\_DevOps](https://discuss.kubernetes.io/u/Rabah_DevOps)\
**Post date:** [December 13, 2022, 10:06pm UTC](https://discuss.kubernetes.io/t/the-connection-to-the-server-192-168-1-2-6443-was-refused-did-you-specify-the-right-host-or-port/22260/2 "2022-12-13T22:06:13Z")

</div>

Hello I have the exact same issue on same version of ubuntu server.  
I have also all my pods kube-system is going down and up randomly

---

<div class="post-metadata">

**Author:** ![bestman](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@bestman](https://discuss.kubernetes.io/u/bestman)\
**Post date:** [December 15, 2022, 5:31am UTC](https://discuss.kubernetes.io/t/the-connection-to-the-server-192-168-1-2-6443-was-refused-did-you-specify-the-right-host-or-port/22260/3 "2022-12-15T05:31:00Z")

</div>

I did a lot of things and finally I found that, the problem is because of the `kublet` service. And the problem for `kubelet` service one of the `CNI` or `Docker` service. I tried to remove and reinstall them again, then `kubeadm init` command worked.

I think the best way to resolve Kubernetes problems is checking related services status like `kubelet` , `docker`, `containerd` , `CNI` and if they all are fine and work correctly, I think `kubectl` also should work fine as well. If they have problems, it’s better to reconfigure them to resolve their problems.

---

<div class="post-metadata">

**Author:** ![Rabah\_DevOps](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/rabah_devops/32/9679_2.png) [@Rabah\_DevOps](https://discuss.kubernetes.io/u/Rabah_DevOps)\
**Post date:** [December 15, 2022, 11:47am UTC](https://discuss.kubernetes.io/t/the-connection-to-the-server-192-168-1-2-6443-was-refused-did-you-specify-the-right-host-or-port/22260/4 "2022-12-15T11:47:38Z")

</div>

I found also the issue, for me it was coming from kernel version and contairnerd config.  
This link describe all step to install kubernetes cluster on debian 11.  
[install kube on debian 11](https://www.linuxtechi.com/install-kubernetes-cluster-on-debian/)

---

<div class="post-metadata">

**Author:** ![Fernando1612](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/fernando1612/32/11448_2.png) [@Fernando1612](https://discuss.kubernetes.io/u/Fernando1612)\
**Post date:** [December 25, 2022, 9:10pm UTC](https://discuss.kubernetes.io/t/the-connection-to-the-server-192-168-1-2-6443-was-refused-did-you-specify-the-right-host-or-port/22260/5 "2022-12-25T21:10:25Z")

</div>

You need to disable swap on the system for kubelet to work. You can disable swap with `sudo swapoff -a` and restart kubelet service `sudo systemctl restart kubelet`

---

<div class="post-metadata">

**Author:** ![mayank08022022](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@mayank08022022](https://discuss.kubernetes.io/u/mayank08022022)\
**Post date:** [June 17, 2023, 3:53am UTC](https://discuss.kubernetes.io/t/the-connection-to-the-server-192-168-1-2-6443-was-refused-did-you-specify-the-right-host-or-port/22260/6 "2023-06-17T03:53:32Z")

</div>

I am also facing same issue and found below steps helped me to get over come from this issue. it is issue with “kubectl” config even you install packages, need to performed more steps to get worked.

Solution:

Step1: On “Worker node/Compute node” look for file "/etc/kubernetes/admin.conf ", If it is not available than “Copy paste/SCP” from your “Controller node/master node”.

Step2: On “Worker Node/Compute node” create a directory called “.kube” on user home directory, if it is already exist than Not to worry and move inside this directory.

mkdir ~/.kube  
or,  
mkdir -p $HOME/.kube

cd ~/.kube

Step3: Create file called “config” and paste the content of “/etc/kubernetes/admin.conf”.  
vi config

Note:- while Copy the content on config file make sure the below mention parameter has correct master IP mentioned, Some time it is localhost but try to update master IP.

E.g:  
server: [https://192.168.1.247:6443](https://192.168.1.247:6443)  
name: kubernetes

Thank you, Hope this will work for you.

---

<div class="post-metadata">

**Author:** ![smit](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/smit/32/13076_2.png) [@smit](https://discuss.kubernetes.io/u/smit)\
**Post date:** [August 12, 2023, 10:14pm UTC](https://discuss.kubernetes.io/t/the-connection-to-the-server-192-168-1-2-6443-was-refused-did-you-specify-the-right-host-or-port/22260/7 "2023-08-12T22:14:29Z")

</div>

In my case, firewall was the real culprit:

- If you are trying to connect to a remote server, first try to use `telnet` command to check if you can connect to that port.
- If its refusing connection, check if the port you are trying to connect is listed:

```auto
sudo ufw status

```

- If its not listed, just add it

```auto
sudo ufw allow 6443

```

- You can deny access on certain ports as well:

```auto
sudo ufw deny [port]

```

---

<div class="post-metadata">

**Author:** ![jovyllebermudez](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/jovyllebermudez/32/15383_2.png) [@jovyllebermudez](https://discuss.kubernetes.io/u/jovyllebermudez)\
**Post date:** [July 16, 2024, 5:40am UTC](https://discuss.kubernetes.io/t/the-connection-to-the-server-192-168-1-2-6443-was-refused-did-you-specify-the-right-host-or-port/22260/8 "2024-07-16T05:40:35Z")

</div>

> [@Fernando1612](#):
>
> sudo systemctl restart kubelet

Righttt ! Thank you. I forgot about this. how would we permanently disable swapoff it came back after restart/reboot

Edit: I searched and this is how to disable swap and persist it

sudo nano /etc/fstab  
and

comment line for swap by adding “#” in front.

#/swap.img none swap sw 0 0

---

<div class="post-metadata">

**Author:** ![sivehost](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/sivehost/32/16644_2.png) [@sivehost](https://discuss.kubernetes.io/u/sivehost)\
**Post date:** [January 7, 2025, 12:10pm UTC](https://discuss.kubernetes.io/t/the-connection-to-the-server-192-168-1-2-6443-was-refused-did-you-specify-the-right-host-or-port/22260/9 "2025-01-07T12:10:08Z")

</div>

sudo nano /etc/containerd/config.toml  
Then find SystemdCgroup change its value from false to true

sudo systemctl restart containerd;sudo reboot  
Check for details:

> **[Who's killing my pods? | (blog 'zezin)](https://gjhenrique.com/cgroups-k8s/)**
>
> Minimalistic Hugo blogging theme

> [@Why does etcd fail with Debian/bullseye kernel?](https://discuss.kubernetes.io/t/why-does-etcd-fail-with-debian-bullseye-kernel/19696):
>
> I while ago I tried to upgrade my system from Debian buster to Debian bulleye. But etcd stops working. So I downgraded the kernel back to the buster version, and that fixed the problem. I posted my experiences on stack overflow, which appeared to be the correct place to get support for Kubernetes, but it was closed with “We don’t allow questions about general computing hardware and software on Stack Overflow” which doesn’t make a lot of sense to me. This isn’t a general question IMHO. In hindsight maybe I should have emphasized this is a kubernetes system, that I was trying to upgrade. But no…

---

<div class="post-metadata">

**Author:** ![Michal\_Chomiczewski](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/michal_chomiczewski/32/17244_2.png) [@Michal\_Chomiczewski](https://discuss.kubernetes.io/u/Michal_Chomiczewski)\
**Post date:** [May 2, 2025, 6:37pm UTC](https://discuss.kubernetes.io/t/the-connection-to-the-server-192-168-1-2-6443-was-refused-did-you-specify-the-right-host-or-port/22260/10 "2025-05-02T18:37:31Z")

</div>

Had same problem. For me it was a case of bad containerd installation.  
Instead of this:  
udo sysctl --system  
sudo apt install -y containerd  
sudo systemctl start containerd && sudo systemctl enable containerd

I followed steps outlined at [LinuxTechi (for Ubuntu 20.04 as that is my install)](https://www.linuxtechi.com/install-kubernetes-on-ubuntu-22-04/) Namely (this example also includes prerequisites so it’s longer than above):

sudo apt install -y curl gnupg2 software-properties-common apt-transport-https ca-certificates  
sudo curl -fsSL [https://download.docker.com/linux/ubuntu/gpg](https://download.docker.com/linux/ubuntu/gpg) | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/docker.gpg  
sudo add-apt-repository “deb [Index of linux/ubuntu/](https://download.docker.com/linux/ubuntu) $(lsb\_release -cs) stable”  
sudo apt-get update  
sudo apt install -y [containerd.io](http://containerd.io)  
containerd config default | sudo tee /etc/containerd/config.toml \>/dev/null 2\>&1  
sudo sed -i ‘s/SystemdCgroup = false/SystemdCgroup = true/g’ /etc/containerd/config.toml  
sudo systemctl restart containerd  
sudo systemctl enable containerd

With containerd installed in this way (no docker BTW) - it all works now.  
As I write this, latest k8s is 1.33, which is what I’m installing. I am getting an inconsistency warning, but it still works. With future versions… your milage may vary.

Hope this helps someone,  
Michael
