When using a DB as a service in pipelines the build fails with Unknown MySQL server host

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

When using a DB as a service in pipelines the build fails with ERROR 2005 (HY000): Unknown MySQL server host 'host.docker.internal:xxxx'.

1 2 3 script: - sudo systemctl start mysql - mysql -user -password -h xxx.x.x.x:xxxx databasename < xxxx.sql

Cause

In some instances, commands in a docker that utilize DB services, or other services that can take a few moments to start, execute before the corresponding service is completely online. In these instances, an error will occur in finding the service within the contain as the service is not available yet. Typically the error is "Unknown <service same> host".

Solution

Since the issue is a timing issue, to work around the issue we can add a sleep command to delay the execution of the subsequent steps. This will give time for the service to become available. In pipelines the sleep can be added as follows after the start command for any service to give the service time to fully be available for follow up commands. You can increase the sleep time if the initial service needs additional time to start.

1 2 3 4 script: - sudo systemctl start mysql - sleep 30 - mysql -user -password -h xxx.x.x.x:xxxx databasename < xxxx.sql
Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.