Unable to connect MySql server from the Nodejs application
MySql server installed in windows - 7.
Oracle Virtual Box installed in Windows - 7 The Oracle virtual Box contains nodejs application and related packages.
Note: The Virtual box does not have the MySql server.
I am trying to connect mySql server(which is available in windows-7) from my nodejs application. The nodejs application running in the Oracle Virtual box(Linux)
The following error message I am getting when I run the nodejs application.
Error Message: events.j2:72 throw er; //unhandled 'error' event
Error: connect ECONNREFUSED at errnoException(net.js:901:11)
It is hard to answer this, because the description is very confusing. However, I think it could be, that mysql might be bound to the loopback interface only. You should check in my.cnf and set
bind-address=0.0.0.0
or similar.
You have a number of options here.
If you really wish to your MySQL on Windows you have two separate options:
Personally, I would avoid both of those above paths. Instead I would install MySQL on the Linux VM. This will provide a number of benefits like your entire application being sandboxed. In addition, you will not have to deal with silly virtual networking configurations as your nodejs application can connect to MySQL @ localhost.
From there you can set your virtual machine networking mode to NAT and open host ports (Your Windows Machine) to point to guest ports (your VM). By doing this you can effectively run your entire application stack in a Linux VM and access it in Windows without issue.