Issue
My node.js program use the mysql module which I use with xampp. Why does it (sometime)require an internet connection to connect to my db in localhost using the mysql node module while other times it works fine while offline? It won't connect to my db which looks fine in phpmyadmin while offline but once I tried while online then it worked for a while offline then it seems to require internet once again. Why?
Solution
Behalf on using 'localhost' as your host you should use '127.0.0.1' That Will solve your problem
const host='127.0.0.1';
const user='root';
const password='root';
const database='node_db'
var connection = mysql.createConnection({
host:host,
user:user,
password: password,
database: database
})
Answered By - Pratik Hublikar
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.