# Connection dabatase in Ignition

**URL:** <https://forum.inductiveautomation.com/t/connection-dabatase-in-ignition/97796>\
**Category:** Maker\
**Created:** [October 25, 2024, 8:10pm UTC](https://forum.inductiveautomation.com/t/connection-dabatase-in-ignition/97796 "2024-10-25T20:10:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [October 25, 2024, 8:10pm UTC](https://forum.inductiveautomation.com/t/connection-dabatase-in-ignition/97796/1 "2024-10-25T20:10:59Z")

</div>

Hello everyone,  
I am using docker with ignition and mysql

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/e/0ee60c9e935c39c2875c17b5328b9b4a86dfc6eb.png)

my mysql

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/1/61f64e50111703b00a7426d7df21d945ca09e46a.png)i

but in the gateway when I create a connection with mysql says this:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/1/71286441fe98c7d08170f949bda3d6e9bab9a9ee.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/9/19049e23b366d1a99fb0a0e4868d5caeb9eb96f3.png)

and the error details says:  
`Cannot create PoolableConnectionFactory (Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)`

I can use my connection in mysql and I can do selects to my database

I forgot to add where I am creating the image for mysql, myabe is from here

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/b/ebb366602afe482dae28732e6bce849533d7af45.png)

---

<div class="post-metadata">

**Author:** ![Marcus\_Sysum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/marcus_sysum/32/57944_2.png) [@Marcus\_Sysum](https://forum.inductiveautomation.com/u/Marcus_Sysum)\
**Post date:** [October 25, 2024, 8:37pm UTC](https://forum.inductiveautomation.com/t/connection-dabatase-in-ignition/97796/2 "2024-10-25T20:37:11Z")

</div>

@Esme_Lopez Your mapping port 3306 inside docker to an external port of 3307. Because ignition is inside docker on the docker internal network your connection string should have the port of 3306. Try changing this to

```python
jdbc:mysql://localhost:3306/test_db

```

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [October 25, 2024, 8:49pm UTC](https://forum.inductiveautomation.com/t/connection-dabatase-in-ignition/97796/3 "2024-10-25T20:49:15Z")

</div>

In this case, `jdbc:mysql://localhost:3307/test_db` inside of your Ignition container points to localhost _in the container_, not your host machine (where you're publishing the port `3307` to connect into the mysql container's `3306`. Since MySQL isn't running alongside Ignition within the same container, there is nothing listening on `localhost:3306` from Ignition's network context.

~~Since these are standalone containers, they're likely bound to the default `bridge` network managed by Docker. This network doesn't do any name-based DNS resolution like other bridge networks do (such as those created by a Docker Compose stack). This means that you'll want to "loopback" to your host from within the container. Try the following:~~

~~`jdbc:mysql://host.docker.internal:3307/test_db`~~

EDIT: actually, looking at your update, it _does_ appear that you're in a Compose stack. In this case, you should actually be able to use the following:

`jdbc:mysql://database-mysql:3306/test_db`

... since within the dedicated bridge network your two Compose services (i.e. containers) are attached to, you can resolve other containers by their service name, e.g. `database-mysql`. Since you're connecting directly, you use the port that the container itself is listening on. At this point, you'd only be using the published port `3307` for your workbench connection from your host.

Here is a reference for more information: [Explore networking features on Docker Desktop | Docker Docs](https://docs.docker.com/desktop/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host)

---

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [October 25, 2024, 9:16pm UTC](https://forum.inductiveautomation.com/t/connection-dabatase-in-ignition/97796/4 "2024-10-25T21:16:20Z")

</div>

this worked: jdbc:mysql://database-mysql:3306/test\_db  
also I changed ports in my compose 3306:3306

Thank you so much for your time

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 26, 2024, 12:16am UTC](https://forum.inductiveautomation.com/t/connection-dabatase-in-ignition/97796/5 "2024-10-26T00:16:03Z")

</div>

Tip: we don't edit the title with "[Solved]" in it. Accepting the solution adds the solved check mark to the question on the main index and adds the "solution" right below your original post. I've removed it for you.
