Issue
I have a server on a raspberry pi with a local DB I used href="https://pimylifeup.com/raspberry-pi-mysql/comment-page-1/?unapproved=88283&moderation-hash=25737290e2aa3ed1579079adb5d64088#comment-88283" rel="nofollow noreferrer">this guide to setup my database.
this is my connector in nodejs:
knexDb = knex({ client: ‘mysql’,
connection: { host: “localhost”,
user: “myUsername”,
password: “MyPassword”,
port: 3306,
database: “DBName” }
});
But when I try to access it with postman I get this error:
{
“errno”: -111,
“code”: “ECONNREFUSED”,
“syscall”: “connect”,
“address”: “::1”,
“port”: 3306,
“fatal”: true
}
The nodejs is running, and I can access the DB on the raspberry pi, I have been searching on google but I haven't been able to find a solution only that the nodejs can't connect to the DB.
Solution
Changing the host from 'localhost'
to '127.0.0.1'
worked
Answered By - TWOcvfan Answer Checked By - Marie Seifert (WPSolving Admin)