Error: connect ECONNREFUSED 127.0.0.1:3306

Hello I’m new using GitLab(Today is the first time that I have used it), I have to use it for educational porpuses. I have worked on a project that has to connect with mysql, when I run the npm start on the terminal of VSC or Command Prompt, the application runs without problems and everything works fine, but when the pipeline is running the deploy stage, that is basically the npm start, it gives an ECONNREFUSED error.

I want to know Why i’m having this error and if it its possible to fix, this is the .git-lab-ci.yml

I hope you could help me with this problem, regards!

Hi,

the deploy_Application job needs access to a running MySQL instance, after invoking npm start. 127.0.0.1 is not available in this scenario, think of accessing the service name specifically.

Following https://docs.gitlab.com/runner/executors/docker.html#accessing-the-services I would say that you need to change your npm configuration to use mysql as host name, from the services key.

Cheers,
Michael

1 Like