MySQL is not connecting. (Driver installed, and logs are in the Details)
Asked by SnailDOS:

Hello! Recently, I just wanted to start a migration, I press on "Migrate" and type in these details.

![Afasd.png](/t5/image/serverpage/image-id/122702i83CFC2176CE16090/image-size/large?v=v2&px=999 "Afasd.png")Now this is what happens, I cannot connnect!

Here is the logs:

itbucket \| The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.  
bitbucket \| at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)  
bitbucket \| at com.atlassian.stash.internal.db.DefaultDatabaseValidator.validate(DefaultDatabaseValidator.java:43)  
bitbucket \| at com.atlassian.stash.internal.db.DefaultDatabaseManager.validateConfiguration(DefaultDatabaseManager.java:214)  
bitbucket \| at com.atlassian.stash.internal.migration.DefaultDatabaseMigrationService.validateConfiguration(DefaultDatabaseMigrationService.java:85)  
bitbucket \| at com.atlassian.stash.internal.web.admin.DbConfigurationController.testAndMigrateDbConfig(DbConfigurationController.java:97)  
bitbucket \| at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
bitbucket \| at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
bitbucket \| at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
bitbucket \| at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
bitbucket \| at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
bitbucket \| at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)  
bitbucket \| at com.atlassian.bitbucket.internal.ratelimit.servlet.filter.RateLimitFilter.doFilter(RateLimitFilter.java:75)  
bitbucket \| at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)  
bitbucket \| at com.atlassian.stash.internal.web.auth.AuthorizationFailureInterceptor.doFilterInternal(AuthorizationFailureInterceptor.java:39)  
bitbucket \| at com.atlassian.stash.internal.spring.security.StashAuthenticationFilter.doFilter(StashAuthenticationFilter.java:85)  
bitbucket \| at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doInsideSpringSecurityChain(BeforeLoginPluginAuthenticationFilter.java:112)  
bitbucket \| at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:75)  
bitbucket \| at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94)  
bitbucket \| at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67)  
bitbucket \| at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)  
bitbucket \| at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)  
bitbucket \| at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94)  
bitbucket \| at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67)  
bitbucket \| at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)  
bitbucket \| at com.atlassian.plugin.connect.plugin.auth.oauth2.DefaultSalAuthenticationFilter.doFilter(DefaultSalAuthenticationFilter.java:69)  
bitbucket \| at com.atlassian.plugin.connect.plugin.auth.user.ThreeLeggedAuthFilter.doFilter(ThreeLeggedAuthFilter.java:109)  
bitbucket \| at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:37)  
bitbucket \| at com.atlassian.analytics.client.filter.DefaultAnalyticsFilter.doFilter(DefaultAnalyticsFilter.java:26)  
bitbucket \| at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:48)  
bitbucket \| at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)  
bitbucket \| at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doBeforeBeforeLoginFilters(BeforeLoginPluginAuthenticationFilter.java:90)  
bitbucket \| at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:73)  
bitbucket \| at com.atlassian.stash.internal.request.DefaultRequestManager.doAsRequest(DefaultRequestManager.java:81)  
bitbucket \| at com.atlassian.stash.internal.hazelcast.ConfigurableWebFilter.doFilter(ConfigurableWebFilter.java:38)  
bitbucket \| at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)  
bitbucket \| at java.lang.Thread.run(Thread.java:748)  
bitbucket \| ... 309 frames trimmed  
bitbucket \| Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure  
bitbucket \|  
bitbucket \| The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.  
bitbucket \| at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
bitbucket \| at com.mysql.jdbc.Util.handleNewInstance(Util.java:403)  
bitbucket \| at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)  
bitbucket \| at com.mysql.jdbc.MysqlIO.\<init\>(MysqlIO.java:335)  
bitbucket \| at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2187)  
bitbucket \| at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2220)  
bitbucket \| at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2015)  
bitbucket \| at com.mysql.jdbc.ConnectionImpl.\<init\>(ConnectionImpl.java:768)  
bitbucket \| at com.mysql.jdbc.JDBC4Connection.\<init\>(JDBC4Connection.java:47)  
bitbucket \| at com.mysql.jdbc.Util.handleNewInstance(Util.java:403)  
bitbucket \| at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:385)  
bitbucket \| at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:323)  
bitbucket \| at java.sql.DriverManager.getConnection(DriverManager.java:664)  
bitbucket \| at java.sql.DriverManager.getConnection(DriverManager.java:208)  
bitbucket \| at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:155)  
bitbucket \| at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:146)  
bitbucket \| at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:205)  
bitbucket \| at org.springframework.jdbc.datasource.SingleConnectionDataSource.initConnection(SingleConnectionDataSource.java:224)  
bitbucket \| at org.springframework.jdbc.datasource.SingleConnectionDataSource.getConnection(SingleConnectionDataSource.java:164)  
bitbucket \| at org.springframework.jdbc.datasource.DelegatingDataSource.getConnection(DelegatingDataSource.java:99)  
bitbucket \| at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158)  
bitbucket \| at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116)  
bitbucket \| at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)  
bitbucket \| ... 36 common frames omitted  
bitbucket \| Caused by: java.net.ConnectException: Connection refused (Connection refused)  
bitbucket \| at java.net.PlainSocketImpl.socketConnect(Native Method)  
bitbucket \| at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)  
bitbucket \| at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)  
bitbucket \| at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)  
bitbucket \| at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)  
bitbucket \| at java.net.Socket.connect(Socket.java:607)  
bitbucket \| at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)  
bitbucket \| at com.mysql.jdbc.MysqlIO.\<init\>(MysqlIO.java:299)  
bitbucket \| ... 55 common frames omitted  
bitbucket \| 2020-12-18 09:13:16,751 WARN \[http-nio-7990-exec-9\] SnailDOS @1UI3O4Mx553x54x0 8znbdg 172.19.0.1 "POST /admin/db/edit HTTP/1.0" c.a.s.i.db.DefaultDatabaseManager A connection could not be opened with the DataSource  
bitbucket \| org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure  
bitbucket \|  
bitbucket \| The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.  
bitbucket \| at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)  
bitbucket \| at com.atlassian.stash.internal.db.DefaultDatabaseValidator.validate(DefaultDatabaseValidator.java:43)  
bitbucket \| at com.atlassian.stash.internal.db.DefaultDatabaseManager.validateConfiguration(DefaultDatabaseManager.java:214)  
bitbucket \| at com.atlassian.stash.internal.migration.DefaultDatabaseMigrationService.validateConfiguration(DefaultDatabaseMigrationService.java:85)  
bitbucket \| at com.atlassian.stash.internal.web.admin.DbConfigurationController.testAndMigrateDbConfig(DbConfigurationController.java:97)  
bitbucket \| at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
bitbucket \| at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
bitbucket \| at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
bitbucket \| at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
bitbucket \| at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)  
bitbucket \| at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)  
bitbucket \| at com.atlassian.bitbucket.internal.ratelimit.servlet.filter.RateLimitFilter.doFilter(RateLimitFilter.java:75)  
bitbucket \| at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)  
bitbucket \| at com.atlassian.stash.internal.web.auth.AuthorizationFailureInterceptor.doFilterInternal(AuthorizationFailureInterceptor.java:39)  
bitbucket \| at com.atlassian.stash.internal.spring.security.StashAuthenticationFilter.doFilter(StashAuthenticationFilter.java:85)  
bitbucket \| at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doInsideSpringSecurityChain(BeforeLoginPluginAuthenticationFilter.java:112)  
bitbucket \| at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:75)  
bitbucket \| at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94)  
bitbucket \| at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67)  
bitbucket \| at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)  
bitbucket \| at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)  
bitbucket \| at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94)  
bitbucket \| at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67)  
bitbucket \| at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)  
bitbucket \| at com.atlassian.plugin.connect.plugin.auth.oauth2.DefaultSalAuthenticationFilter.doFilter(DefaultSalAuthenticationFilter.java:69)  
bitbucket \| at com.atlassian.plugin.connect.plugin.auth.user.ThreeLeggedAuthFilter.doFilter(ThreeLeggedAuthFilter.java:109)  
bitbucket \| at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:37)  
bitbucket \| at com.atlassian.analytics.client.filter.DefaultAnalyticsFilter.doFilter(DefaultAnalyticsFilter.java:26)  
bitbucket \| at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:48)  
bitbucket \| at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)  
bitbucket \| at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doBeforeBeforeLoginFilters(BeforeLoginPluginAuthenticationFilter.java:90)  
bitbucket \| at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:73)  
bitbucket \| at com.atlassian.stash.internal.request.DefaultRequestManager.doAsRequest(DefaultRequestManager.java:81)  
bitbucket \| at com.atlassian.stash.internal.hazelcast.ConfigurableWebFilter.doFilter(ConfigurableWebFilter.java:38)  
bitbucket \| at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)  
bitbucket \| at java.lang.Thread.run(Thread.java:748)  
bitbucket \| ... 309 frames trimmed  
bitbucket \| Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure  
bitbucket \|  
bitbucket \| The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.  
bitbucket \| at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
bitbucket \| at com.mysql.jdbc.Util.handleNewInstance(Util.java:403)  
bitbucket \| at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)  
bitbucket \| at com.mysql.jdbc.MysqlIO.\<init\>(MysqlIO.java:335)  
bitbucket \| at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2187)  
bitbucket \| at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2220)  
bitbucket \| at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2015)  
bitbucket \| at com.mysql.jdbc.ConnectionImpl.\<init\>(ConnectionImpl.java:768)  
bitbucket \| at com.mysql.jdbc.JDBC4Connection.\<init\>(JDBC4Connection.java:47)  
bitbucket \| at com.mysql.jdbc.Util.handleNewInstance(Util.java:403)  
bitbucket \| at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:385)  
bitbucket \| at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:323)  
bitbucket \| at java.sql.DriverManager.getConnection(DriverManager.java:664)  
bitbucket \| at java.sql.DriverManager.getConnection(DriverManager.java:208)  
bitbucket \| at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:155)  
bitbucket \| at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:146)  
bitbucket \| at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:205)  
bitbucket \| at org.springframework.jdbc.datasource.SingleConnectionDataSource.initConnection(SingleConnectionDataSource.java:224)  
bitbucket \| at org.springframework.jdbc.datasource.SingleConnectionDataSource.getConnection(SingleConnectionDataSource.java:164)  
bitbucket \| at org.springframework.jdbc.datasource.DelegatingDataSource.getConnection(DelegatingDataSource.java:99)  
bitbucket \| at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158)  
bitbucket \| at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116)  
bitbucket \| at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)  
bitbucket \| ... 36 common frames omitted  
bitbucket \| Caused by: java.net.ConnectException: Connection refused (Connection refused)  
bitbucket \| at java.net.PlainSocketImpl.socketConnect(Native Method)  
bitbucket \| at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)  
bitbucket \| at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)  
bitbucket \| at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)  
bitbucket \| at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)  
bitbucket \| at java.net.Socket.connect(Socket.java:607)  
bitbucket \| at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)  
bitbucket \| at com.mysql.jdbc.MysqlIO.\<init\>(MysqlIO.java:299)  
bitbucket \| ... 55 common frames omitted

This is really annoying. I don't know what to do.

Pinging the server works, the MariaDB server is up, and yes, its running on the same device as Bitbucket.

Bitbucket is running a docker container, and the MariaDB is running on the host machine.


Answers:
author: Daniel Ebers
body: Hi Zara,

from "just looking" at the log you posted I'd confirm what Bitbucket is complaining about - the database cannot be reached.

As to the way: it is very hard to pinpoint it from the outside. Further inspection by you on the server will be needed, indeed.

Have you checked if there are more information available from database logfile - otherwise more basic configuration like in Docker and/or some kind of firewall blocking access to the database?

Regards,  
Daniel

comments: author: SnailDOS
body: Hey Daniel,

Thanks for your reply, I don't think its a issue with mysql and instead I think it's a issue with the JBDC driver, do you have a DIRECT download too it?


author: Daniel Ebers
body: What I can suggest is the following page:  
<https://confluence.atlassian.com/bitbucketserver/connecting-bitbucket-server-to-mysql-776640382.html>

Is this what you were looking for?


Tags: bitbucket-server

server