Laravel php artisan mysql connection refused



Hi, I’m getting the laravel migrations failed problem.

SQLSTATE[HY000] [2002] Connection refused

I have a custom private docker image. It builds fine on my mac locally. I can’t seem to figure out how to get the logs to display in Circleci after these commands fail (I have an install script.)

I have tried the localhost stuff.

Is there a chance that circleci is overruling my mysql user name? I can’t see how it could in the remote docker execution environment.

What other info is needed to troubleshoot this? (P.S. - I also can’t build locally - due to the remote docker needs of the local circleCI build tool)

Something seems to possibly smell funny with MySQL not starting. I wonder how to check that out.


Might be related to Prevent race conditions by waiting for services with Dockerize


trying that out. I saw that post before and I wasn’t sure if I could run my setup script in my own environment why this would behave different.

Also - it’s really not clear what technique I should use to determine if it is mysql, or something else.


You need to specify as the host so MySQL uses TCP. If you have a config, you’ll need to update that. We only expose port 3306 not the socket file. Also, be sure to load MySQL as an image with the necessary env vars:

EDIT: I recommend using one of our convenience images as it has performance tweaks included:

You can find the tweaks in this repo:

Setting up mysql 5.7 environment variables - Access denied for user (Laravel project)