Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

Giesburts

So I am working with Loopback (Node.js framework) for the first time and I tried to set up a Mysql model. I've installed Loopback globally, and also installed the mysql connector with npm. After that, I tried to add a datasource with the mysql connector. I tried to use my MAMP localhost database.

Unfortunatly I get an error when I try to connect with loopback again typing the node . command. The error: Error: connect ECONNREFUSED 127.0.0.1:3306.

So I did some research and many people answered on different node questions saying you have to add the socket of MAMP to your config in order to get a connection. So I tried to add that but that doesn't seem to work or I am not doing it right, because, I can't find the proper way of doing it. Here is my datasource:

  "db": {
    "host": "127.0.0.1",
    "port": "3306",
    "url": "",
    "database": "meetups",
    "password": "root",
    "name": "root",
    "user": "root",
    "connector": "mysql"
  }

And I tried to add "socketPath": "/var/run/mysqld/mysqld.sock" and "socket": "/var/run/mysqld/mysqld.sock" but that doesn't seem to work. Is there anybody out there with exp. in node.js / loopback?

Giesburts

After researching the Loopback MySQL docs I have found out that you can use additional parameters supported by node-mysql, that's located here.

At the Connection options I found socketPath. So that's actually the parameter for socket when using MAMP. After using that, and also removing the url parameter, the connection worked with this:

  "db": {
    "host": "127.0.0.1",
    "port": 3306,
    "database": "meetups",
    "password": "root",
    "name": "db",
    "user": "root",
    "connector": "mysql",
    "socketPath": "/Applications/MAMP/tmp/mysql/mysql.sock"
  }

The only problem I got after was something with the database tables. I had to autoimigrate them for some reason, don't exactly knew what that was but I found the solution over here. I tried the Grunt automigrate task and now my loopback backend with MySQL works fine so far.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Error: connect ECONNREFUSED 127.0.0.1:8080 (Spring Framework)

java.net.ConnectException : Failed to connect to localhost/0:0:0:0:0:0:0:1:1731 using ChromeDriver Chrome through Selenium Java in Spring Bot

node proxy error Error: connect ECONNREFUSED

npm installation error connect ECONNREFUSED 127.0.0.1:8080

npm ERR! Error: connect ECONNREFUSED

Getting error "connect ECONNREFUSED 127.0.0.1:3306" while connecting to mysql

IPv6 loopback address http://0:0:0:0:0:0:0:1 - browser can't connect. Method getRemoteHost()

Error: connect ECONNREFUSED 127.0.0.1:3306 when using cloud sql for MYSQL from NodeJS app

Docker Compose getting error ECONNREFUSED 127.0.0.1:3306 with MySQL and NodeJS

Error: connect ECONNREFUSED 127.0.0.1:3306 on MySQL, Heroku, and Node.js

certificate Error SSL_connect returned=1 errno=0 state=error: certificate verify failed

Docker Compose connect ECONNREFUSED 172.18.0.4:3306

ERROR: connect ECONNREFUSED 127.0.0.1:5432 docker migrate

Selenium webdriver Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:9515

docker mysql with Error: connect ECONNREFUSED

axios request Error: connect ECONNREFUSED

SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306

Docker Ruby SSL_connect returned=1 errno=0 state=error: wrong signature type

Error: connect ECONNREFUSED 127.0.0.1:8080

ERROR: connect ECONNREFUSED 127.0.0.1:5432 on Gitlab CI

Error in Bugzilla Reporting extension Notice: unserialize(): Error at offset 0 of 127 bytes

0–127 range limit on WEXITSTATUS in old Unix?

Error in Microsoft Bot Emulator: connect ECONNREFUSED 127.0.0.1

Get error connect ECONNREFUSED 127.0.0.1:3306 when start my node.js app

Executed 0 of 1 (skipped 1) ERROR in Jasmine

Heroku error: "connect ECONNREFUSED 127.0.0.1:3306" when trying to deploy Express + React application

POSTMAN in Docker GET error (connect ECONNREFUSED)

Error: connect ECONNREFUSED 127.0.0.1:3716

Getting 'connect ECONNREFUSED ::1:3000' error while sending POST request by axios