curl:unresolved host. i have this error when i try to connect to nginx server

12/3/2020

I am trying to connect to an Nginx server with Minikube, through a NodePort-type service, running on Amazon Linux 2, to obtain the Nginx server welcome page. But when I try to I have this error:

[root@ip-172-31-8-201 ~]# minikube ip
! Executing "docker container inspect minikube --format={{.State.Status}}" took an unusually long time: 2.137525008s
* Restarting the docker service may improve performance.
192.168.49.2
[root@ip-172-31-8-201 ~]# curl 192.168.49.2:30123
curl: (7) Failed to connect to 192.168.49.2 port 30123: Connection refused

I have a file svcNodeport.yaml whcih consists of this:

<!-- language: lang-yaml -->
apiVersion: v1
kind: Service
metadata:
  name: nginx-nodeport
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 8080
    nodePort: 30123
  selector:
    app: nginx

I have a file pod.yaml

<!-- language: lang-yaml -->
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
  containers:
 - image: nginx
   name: nginx
 ports:
   - containerPort: 8080
     protocol: TCP

svc.yaml

<!-- language: lang-yaml -->
apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: nginx

last file pod4svc.yaml

<!-- language: lang-yaml -->
apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx
spec:
  replicas: 1
  selector:
    app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 8080

Any suggestion is helpful.

-- Parva Modi
amazon-web-services
curl
kubernetes
minikube

0 Answers