# Can't reach mysql pod via cluster ip but internal pod ip works

**URL:** <https://discuss.kubernetes.io/t/cant-reach-mysql-pod-via-cluster-ip-but-internal-pod-ip-works/13924>\
**Category:** General Discussions\
**Created:** [December 4, 2020, 8:05am UTC](https://discuss.kubernetes.io/t/cant-reach-mysql-pod-via-cluster-ip-but-internal-pod-ip-works/13924 "2020-12-04T08:05:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Desmond\_Lim](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/desmond_lim/32/6378_2.png) [@Desmond\_Lim](https://discuss.kubernetes.io/u/Desmond_Lim)\
**Post date:** [December 4, 2020, 8:05am UTC](https://discuss.kubernetes.io/t/cant-reach-mysql-pod-via-cluster-ip-but-internal-pod-ip-works/13924/1 "2020-12-04T08:05:37Z")

</div>

Hi,  
I am trying to create a nodejs application to connect to a mysql database. The mysql database comes from a public repository. Both components run on pods on a minikube cluster.

I followed the tutorial on the microservices chapter however is not able to get the above working. I just cannot connect to the mysql pod using cluster ip.

This is the error I get from the nodejs application. Could you advise if anything I did incorrectly? Thanks.

/home/ddl/nodejs/app.js:19  
if(err) throw err;  
^

Error: connect ECONNREFUSED 10.107.157.35:3306  
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)  
--------------------  
at Protocol.\_enqueue (/home/ddl/nodejs/node\_modules/mysql/lib/protocol/Protocol.js:144:48)  
at Protocol.handshake (/home/ddl/nodejs/node\_modules/mysql/lib/protocol/Protocol.js:51:23)  
at Connection.connect (/home/ddl/nodejs/node\_modules/mysql/lib/Connection.js:116:18)  
at Object. (/home/ddl/nodejs/app.js:18:6)  
at Module.\_compile (internal/modules/cjs/loader.js:999:30)  
at Object.Module.\_extensions…js (internal/modules/cjs/loader.js:1027:10)  
at Module.load (internal/modules/cjs/loader.js:863:32)  
at Function.Module.\_load (internal/modules/cjs/loader.js:708:14)  
at Function.executeUserEntryPoint [as runMain] (internal/modules/run\_main.js:60:12)  
at internal/main/run\_main\_module.js:17:47 {  
errno: ‘ECONNREFUSED’,  
code: ‘ECONNREFUSED’,  
syscall: ‘connect’,  
address: ‘10.107.157.35’,  
port: 3306,  
fatal: true  
}

ddl:Service ddl$ kubectl get pod -o wide  
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES  
mysql 1/1 Running 0 94m 172.17.0.3 minikube   
nodejs 0/1 CrashLoopBackOff 14 49m 172.17.0.4 minikube

ddl:Service ddl$ kubectl describe svc db  
Name: db  
Namespace: default  
Labels: app=webapps  
name=mysql-service  
Annotations:   
Selector: app=webapps,name=mysql-pod  
Type: ClusterIP  
IP: 10.107.157.35  
Port: mysql-def 3306/TCP  
TargetPort: 3306/TCP  
Endpoints:   
Port: mysql-1 33060/TCP  
TargetPort: 33060/TCP  
Endpoints:   
Port: mysql-2 33061/TCP  
TargetPort: 33061/TCP  
Endpoints:   
Session Affinity: None  
Events:

ddl:Service ddl$ kubectl describe pod mysql  
Name: mysql  
Namespace: default  
Priority: 0  
Node: minikube/192.168.99.101  
Start Time: Fri, 04 Dec 2020 14:01:15 +0800  
Labels: app=webapps  
name=mysql  
Annotations:   
Status: Running  
IP: 172.17.0.3  
IPs:  
IP: 172.17.0.3  
Containers:  
database:  
Container ID: docker://c825b6ddc33c40305da6d43d927c6461f87063cd3097f08a335256477a9f3f14  
Image: mysql/mysql-server  
Image ID: docker-pullable://mysql/mysql-server@sha256:5dfceab2e53e7dac983168c5f5d611d9d8e85c3bee7297c24c931d77fbeeaac3  
Port: 3306/TCP  
Host Port: 0/TCP  
State: Running  
Started: Fri, 04 Dec 2020 14:01:21 +0800  
Ready: True  
Restart Count: 0  
Environment:   
Mounts:  
/var/run/secrets/kubernetes.io/serviceaccount from default-token-tkkp6 (ro)  
Conditions:  
Type Status  
Initialized True  
Ready True  
ContainersReady True  
PodScheduled True  
Volumes:  
default-token-tkkp6:  
Type: Secret (a volume populated by a Secret)  
SecretName: default-token-tkkp6  
Optional: false  
QoS Class: BestEffort  
Node-Selectors:   
Tolerations: [node.kubernetes.io/not-ready:NoExecute](http://node.kubernetes.io/not-ready:NoExecute) op=Exists for 300s  
[node.kubernetes.io/unreachable:NoExecute](http://node.kubernetes.io/unreachable:NoExecute) op=Exists for 300s  
Events:

From within the database pod, I can connect into the database via mysql using the pod internal IP but not the cluster IP.

bash-4.2# mysql -h 172.17.0.3 -umysqluser -p  
Enter password:  
Welcome to the MySQL monitor. Commands end with ; or \g.  
Your MySQL connection id is 16  
Server version: 8.0.22 MySQL Community Server - GPL

Copyright © 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its  
affiliates. Other names may be trademarks of their respective  
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql\>

bash-4.2# mysql -h 10.107.157.35 -umysqluser -p  
Enter password:  
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘10.107.157.35’ (111)

### Cluster information:

Kubernetes version: minikube version: v1.15.1  
Cloud being used: bare-metal  
Installation method:  
Host OS: MAC OS X  
CNI and version:  
CRI and version:

You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.

---

<div class="post-metadata">

**Author:** ![animesh1008](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/animesh1008/32/12249_2.png) [@animesh1008](https://discuss.kubernetes.io/u/animesh1008)\
**Post date:** [April 10, 2023, 7:51pm UTC](https://discuss.kubernetes.io/t/cant-reach-mysql-pod-via-cluster-ip-but-internal-pod-ip-works/13924/2 "2023-04-10T19:51:20Z")

</div>

I have the same issue. My internal pod works but my backend can’t reach mysql database pod. Please let me know how is this issue resolved.

---

<div class="post-metadata">

**Author:** ![thockin](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/thockin/32/2457_2.png) [@thockin](https://discuss.kubernetes.io/u/thockin)\
**Post date:** [April 10, 2023, 8:02pm UTC](https://discuss.kubernetes.io/t/cant-reach-mysql-pod-via-cluster-ip-but-internal-pod-ip-works/13924/3 "2023-04-10T20:02:12Z")

</div>

> **[Debug Services](https://kubernetes.io/docs/tasks/debug/debug-application/debug-service/)**
>
> An issue that comes up rather frequently for new installations of Kubernetes is that a Service is not working properly. You've run your Pods through a Deployment (or other workload controller) and created a Service, but you get no response when you...
