0Day Forums
Unable to connect to the server: dial tcp: lookup <Server Location>: no such host - Printable Version

+- 0Day Forums (https://0day.red)
+-- Forum: Coding (https://0day.red/Forum-Coding)
+--- Forum: PowerShell & .ps1 (https://0day.red/Forum-PowerShell-ps1)
+--- Thread: Unable to connect to the server: dial tcp: lookup <Server Location>: no such host (/Thread-Unable-to-connect-to-the-server-dial-tcp-lookup-lt-Server-Location-gt-no-such-host)

Pages: 1 2


Unable to connect to the server: dial tcp: lookup <Server Location>: no such host - sondrave - 07-21-2023

I'm beginning to build out a kubernetes cluster for our applications. We are using Azure for cloud services, so my K8s cluster is built using AKS. The AKs cluster was created using the portal interface for Azure. It has one node, and I am attempting to create a pod with a single container to deploy to the node. Where I am stuck currently is trying to connect to the AKS cluster from Powershell.
The steps I have taken are:
```
az login (followed by logging in)
az account set --subscription <subscription id>
az aks get-credentials --name <cluster name> --resource-group <resource group name>
kubectl get nodes
```
After entering the last line, I am left with the error: Unable to connect to the server: dial tcp: lookup <Server Location>: no such host

I've also gone down a few other rabbit holes found on SO and other forums, but quite honestly, I'm looking for a straight forward way to access my cluster before complicating it further.

Edit: So in the end, I deleted the resource I was working with and spun up a new version of AKS, and am now having no trouble connecting. Thanks for the suggestions though!



RE: Unable to connect to the server: dial tcp: lookup <Server Location>: no such host - cordie783 - 07-21-2023

Usually, this is all that is required to connect. Check whether firewall is not blocking any traffic. Also, verify subscription id and other identifiers again and make sure you are using the correct values. If the issue still persists, I recommend you ask azure support to help you out.


RE: Unable to connect to the server: dial tcp: lookup <Server Location>: no such host - cirilo808 - 07-21-2023

Posting this as Community Wiki for better visibility.

**Solution provided by OP:**

*Delete resource and spun up a new version of AKS.*

For details, you can check docs [Create a resource group][1], [Create AKS cluster][2] and [resource create][3].

**Next try worth to try:**

`kubectl config use-context <cluster-name>`

as it was proposed in similar [Github issue][4].

[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

[4]:

[To see links please register here]




RE: Unable to connect to the server: dial tcp: lookup <Server Location>: no such host - sporadism800294 - 07-21-2023

It is more convenient to use [Az][1] module from desktop Powershell for any management operation with Azure portal. Microsoft adds a lot of new cmdlets for managing AKS and Service Fabric clusters.

Please take a look [Az.Aks][2]

In your case:

Connect-AzAccount

Get-AzAksNodePool


[1]:

[To see links please register here]

[2]:

[To see links please register here]




RE: Unable to connect to the server: dial tcp: lookup <Server Location>: no such host - stevenhsxtwh - 07-21-2023

Unable to connect to the server: dial tcp: lookup <Server Location>: no such host

**The error is coming because of private cluster. The Private Cluster option is enabled while creating the AKS cluster. You need to disable this option.**

Kubectl is a kubernetes control client. It is an external connectivity provider to connect with our kubernetes cluster. We can't connect with the private cluster externally.

Believe me.... just disable the private cluster options And see your success. Thank you.


Note: We can't disable this option after the cluster creation. you need to delete the cluster and again reform it.



RE: Unable to connect to the server: dial tcp: lookup <Server Location>: no such host - morgannex - 07-21-2023

I had the same issues when running the kubectl command from **jenkins**. For me it was the permission issues of `~/.kube/config` I gave it access to jenkins as well which solved the issue for me.


RE: Unable to connect to the server: dial tcp: lookup <Server Location>: no such host - porteranthusz - 07-21-2023

Gaurav's answer pretty much sums it up. In fact you can refer to the [documentation][1] which states that

> The API server endpoint has no public IP address. To manage the API
> server, you'll need to use a VM that has access to the AKS cluster's
> Azure Virtual Network (VNet). There are several options for
> establishing network connectivity to the private cluster.

To connect to a private cluster, there are only 3 methods:

> - Create a VM in the same Azure Virtual Network (VNet) as the AKS cluster.
> - Use a VM in a separate network and set up Virtual network peering. See the section below for more information on this option.
> - Use an Express Route or VPN connection.


[1]:

[To see links please register here]




RE: Unable to connect to the server: dial tcp: lookup <Server Location>: no such host - lorenelorens284 - 07-21-2023

I was also facing the issue, I'm using a private cluster and I have a machine (bastion) in a different vnet with peering enabled but still, I was not able to connect the cluster (I was able to SSH and telnet to the machine).

Then I added a virtual network link in the private DNS zone for the vnet where the bastion host resides. It worked for me, I'm able to access the cluster.



RE: Unable to connect to the server: dial tcp: lookup <Server Location>: no such host - zamir302 - 07-21-2023

When using a private cluster, the kubernetes api-endpoint is only accessible on the cluster's VNet. Connecting via VPN unfortunately does not work painlessly since the azure private DNS will not be available via for VPN clients (yet).

However, it is possible to connect kubectl directly to the IP-address of the api-endpoint, but that will require you to ignore certificate errors since we are using the IP directly.

If you edit your `.kube/config` and change the server address to the IP number. Then call `kubectl` with something like this

```
kubectl get all --all-namespaces --insecure-skip-tls-verify
```



RE: Unable to connect to the server: dial tcp: lookup <Server Location>: no such host - Haut566045 - 07-21-2023

You can run `kubectl` commands on a private AKS cluster using `az aks command invoke`. Refer to [this](

[To see links please register here]

) for more info.

As for why you might want to run private AKS clusters, read [this](

[To see links please register here]

)