Failed to get connection to database after update

Hi! I have a Rancher Server online that I set up to do some test a while ago. It uses an external mysql database.

Today I tried updating it (a big jump from 0.5.1 to 1.0.0), but it fails to connect to the database. I haven’t change anything, and I can connect to the db with mysql workbench.
I haven’t used it in a while, so it’s possible that I’m making some very stupid mistake.

This is the command I use:

docker run -p 8080:8080 --restart=always -d -e -e CATTLE_DB_CATTLE_MYSQL_NAME=db -e CATTLE_DB_CATTLE_USERNAME=user -e CATTLE_DB_CATTLE_PASSWORD=password rancher/server

And this is the exception I get:

[pollingConfigurationSource] ERROR i.c.p.a.sources.LazyJDBCSource - Failed to get connection to database, will retry for 5 minutes
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not connect to address=( : connect timed out)
	at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory( ~[commons-dbcp-1.4.jar:1.4]
	at org.apache.commons.dbcp.BasicDataSource.createDataSource( ~[commons-dbcp-1.4.jar:1.4]
	at org.apache.commons.dbcp.BasicDataSource.getConnection( ~[commons-dbcp-1.4.jar:1.4]
	at io.cattle.platform.archaius.sources.LazyJDBCSource.checkInitial( [cattle-framework-archaius-0.5.0-SNAPSHOT.jar:na]
	at io.cattle.platform.archaius.sources.LazyJDBCSource.poll( [cattle-framework-archaius-0.5.0-SNAPSHOT.jar:na]
	at$ [archaius-core-0.5.14.jar:na]
	at java.util.concurrent.Executors$ [na:1.7.0_95]
	at java.util.concurrent.FutureTask.runAndReset( [na:1.7.0_95]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301( [na:1.7.0_95]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ [na:1.7.0_95]
	at java.util.concurrent.ThreadPoolExecutor.runWorker( [na:1.7.0_95]
	at java.util.concurrent.ThreadPoolExecutor$ [na:1.7.0_95]
	at [na:1.7.0_95]
Caused by: java.sql.SQLNonTransientConnectionException: Could not connect to address=( : connect timed out
	at org.mariadb.jdbc.internal.util.ExceptionMapper.get( ~[mariadb-java-client-1.3.4.jar:na]
	at org.mariadb.jdbc.internal.util.ExceptionMapper.throwException( ~[mariadb-java-client-1.3.4.jar:na]
	at org.mariadb.jdbc.Driver.connect( ~[mariadb-java-client-1.3.4.jar:na]
	at org.apache.commons.dbcp.DriverConnectionFactory.createConnection( ~[commons-dbcp-1.4.jar:1.4]
	at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject( ~[commons-dbcp-1.4.jar:1.4]
	at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory( ~[commons-dbcp-1.4.jar:1.4]
	at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory( ~[commons-dbcp-1.4.jar:1.4]
	... 12 common frames omitted
Caused by: org.mariadb.jdbc.internal.util.dao.QueryException: Could not connect to address=( : connect timed out
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy( ~[mariadb-java-client-1.3.4.jar:na]
	at org.mariadb.jdbc.internal.util.Utils.retrieveProxy( ~[mariadb-java-client-1.3.4.jar:na]
	at org.mariadb.jdbc.Driver.connect( ~[mariadb-java-client-1.3.4.jar:na]
	... 16 common frames omitted
Caused by: connect timed out
	at Method) ~[na:1.7.0_95]
	at ~[na:1.7.0_95]
	at ~[na:1.7.0_95]
	at ~[na:1.7.0_95]
	at ~[na:1.7.0_95]
	at ~[na:1.7.0_95]
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connect( ~[mariadb-java-client-1.3.4.jar:na]
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy( ~[mariadb-java-client-1.3.4.jar:na]
	... 18 common frames omitted


It looks like in your comand you are missing

Here’s what it recommends in the docs.

sudo docker run -d --restart=always -p 8080:8080 \
    -e CATTLE_DB_CATTLE_MYSQL_HOST=<hostname or IP of MySQL instance> \
    -e CATTLE_DB_CATTLE_MYSQL_NAME=<Name of Database> \

Also, can you clarify if you’re using v0.56.1? v0.59.1? Just trying to help pinpoint where your jump is from. :slight_smile:

Hi, thanks for the answer!

I’m getting the same error by specifying the port (it was the default anyway).

I’m using the latest version right now. I don’t remeber exactly which one I was using before, but I think 0.5.1

If you were using v0.5.1, then you would have deployed something on the 5th week of 2015 (over a year ago). Prior to v1.0.0, the numbering of our versions were based on the week of the year.

This is why I asked if you were running either v0.56.1 or v0.59.1, there is also v0.51.0.

FYI, if it’s v0.51.0 to v1.0.0, then there are major networking changes that occurred between v0.51.0 to v0.56. The DB migration might take a lot longer.

It seems like you are having a timeout issue (not related to upgrading). Are you able to start up a new rancher/server to connect to the DB to test out your external DB connection?

Pretty safe to assume v0.51.0, as there was no public v0.5.1 tag.

I haven’t tryed with a new rancher/server. I can conect to that db without problems with other tools, though

have you tried launching with just the IP instead of the name of the rds instance?

No, I will try as soon as I have some spare time! :slight_smile:

Just spend a while debugging the same problem. In my case I had a $ sign in the password. Removed it and now it works.