VectleSkillsThe connection to the server YOUR_HOST:8080 was refused - did you specify the right host or port?

The connection to the server YOUR_HOST:8080 was refused - did you specify the right host or port?

Export

Routes kubectl connection-refused-to-loopback failures. Use when kubectl tries YOUR_HOST:8080, which means no kubeconfig was loaded. Not for refusals on a real cluster address (check the server field) or TLS errors.

With no kubeconfig loaded, kubectl falls back to a server on the local loopback at port 8080 - which is not a real cluster. This almost always means your kubeconfig is missing or KUBECONFIG points nowhere. Fetch a fresh config from your provider (EKS, GKE, AKS) or export KUBECONFIG to the right file, then retry.

The error

The connection to the server YOUR_HOST:8080 was refused - did you specify the right host or port?

What to do

  1. Confirm nothing is loaded:
kubectl config view --minify

Expected: Empty clusters/contexts/users, or an error - no config is active.

  1. Find the gap:
echo $KUBECONFIG
ls -la ~/.kube/config

Expected: Shows the unset variable or the missing file.

  1. Rebuild the config, e.g.:
aws eks --region [region] update-kubeconfig --name [cluster]

(GKE: gcloud container clusters get-credentials [cluster] --region [region]; AKS: az aks get-credentials ...) Expected: Context added to ~/.kube/config.

  1. Verify:
kubectl get nodes

Expected: Node list, no connection error.

When this applies

  • the exact YOUR_HOST:8080 connection refused message
  • fresh shells where KUBECONFIG was set in another shell
  • sudo runs that lose the user's env and home

When it does NOT apply

  • connection refused on a real cluster IP or hostname (cluster or network is down)
  • certificate or auth errors (config loaded, creds bad)

Works with

all kubectl versions

The connection to the server [real-host]:6443 was refused

Same words, real address: the cluster itself is unreachable. Check the API server and network instead of the kubeconfig.

Why it happens

kubectl's default server is the loopback on port 8080 when no kubeconfig provides a cluster entry. Nothing listens there on a normal machine, so the OS refuses the connection.

Edge cases

  • Running kubectl with sudo uses root's home and env, so your user's ~/.kube/config and KUBECONFIG vanish - either run as your user or pass --kubeconfig explicitly.
  • On a kubeadm-built cluster, copying /etc/kubernetes/admin.conf to ~/.kube/config as your user fixes this permanently.

Resolved from

gh:tmatin100/troubleshoot (aws/eks troubleshooting doc) - https://github.com/tmatin100/troubleshoot/blob/HEAD/aws/eks/The%20connection%20to%20the%20server%20localhost:8080%20was%20refused.md

Published recentlyPublished Oct 3, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 1, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=The+connection+to+the+server+YOUR_HOST%3A8080+was+refused+-+did+you+specify+the+right+host+or+port%3F&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.