# MySQL Database Connection Faulted

**URL:** <https://forum.inductiveautomation.com/t/mysql-database-connection-faulted/3641>\
**Category:** Ignition\
**Created:** [November 22, 2011, 5:20pm UTC](https://forum.inductiveautomation.com/t/mysql-database-connection-faulted/3641 "2011-11-22T17:20:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [November 22, 2011, 5:20pm UTC](https://forum.inductiveautomation.com/t/mysql-database-connection-faulted/3641/1 "2011-11-22T17:20:35Z")

</div>

After a couple days of working just fine, our database connection faulted with the error below. Any help is greatly appreciated.

` **BEGIN NESTED EXCEPTION**
	java.net.ConnectException
	MESSAGE: Connection refused
		STACKTRACE: 
			java.net.ConnectException: Connection refused at 
			java.net.PlainSocketImpl.socketConnect(Native Method) at 
			java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) at 
			java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213) at 
			java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200) at 
			java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at 
			java.net.Socket.connect(Socket.java:529) at 
			java.net.Socket.connect(Socket.java:478) at 
			java.net.Socket.<init>(Socket.java:375) at 
			java.net.Socket.<init>(Socket.java:218) at 
			com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:173) at 
			com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:268) at 
			com.mysql.jdbc.Connection.createNewIO(Connection.java:2745) at 
			com.mysql.jdbc.Connection.<init>(Connection.java:1553) at 
			com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285) at 
			org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38) at 
			org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294) at 
			org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247) at 
			org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221) at 
			org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880) at 
			com.inductiveautomation.ignition.gateway.datasource.DatasourceImpl.getConnectionInternal(DatasourceImpl.java:189) at 
			com.inductiveautomation.ignition.gateway.datasource.DatasourceImpl.runTest(DatasourceImpl.java:145) at 
			com.inductiveautomation.ignition.gateway.datasource.DatasourceManagerImpl$FaultedDatasourceRetryer.run(DatasourceManagerImpl.java:1117) at
			java.lang.Thread.run(Thread.java:662) 
**END NESTED EXCEPTION** `

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [November 22, 2011, 7:56pm UTC](https://forum.inductiveautomation.com/t/mysql-database-connection-faulted/3641/2 "2011-11-22T19:56:45Z")

</div>

In the database connections, I changed “localhost” to the IP address of the server and the connection works again. We would prefer to use “localhost”. Any suggestions?

Ignition: 7.3.1  
MySQL: 5.1  
OS: Ubuntu 10.04

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [November 22, 2011, 10:00pm UTC](https://forum.inductiveautomation.com/t/mysql-database-connection-faulted/3641/3 "2011-11-22T22:00:37Z")

</div>

We needed to allow external connections to the MySQL database, so we changed changed bind-address in my.conf from 127.0.0.1 to the IP address of the server. Is there a way to allow external connections AND to use ‘localhost’ in the Ignition database connection configuration?

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [November 22, 2011, 11:28pm UTC](https://forum.inductiveautomation.com/t/mysql-database-connection-faulted/3641/4 "2011-11-22T23:28:02Z")

</div>

My hazy recollection of MySql security was that you could tie down users to specific ip addresses. I would think that if you add localhost as an address in your security list, Ignition would be able to use that.

Sorry I don’t have details, maybe one of the MySQL gurus can help out.

---

<div class="post-metadata">

**Author:** ![mgross](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mgross/32/3311_2.png) [@mgross](https://forum.inductiveautomation.com/u/mgross)\
**Post date:** [November 22, 2011, 11:31pm UTC](https://forum.inductiveautomation.com/t/mysql-database-connection-faulted/3641/5 "2011-11-22T23:31:48Z")

</div>

Try commenting out the bind-address line in my.cnf and then restart the MySQL server. It will then bind to localhost automatically, yet external connections can still be used. You can then also use localhost in the MySQL connection parameters within Ignition.

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [November 22, 2011, 11:52pm UTC](https://forum.inductiveautomation.com/t/mysql-database-connection-faulted/3641/6 "2011-11-22T23:52:20Z")

</div>

That fixed it. Thanks!
