Adamhumbug Posted April 22, 2023 Share Posted April 22, 2023 (edited) Hi all, I hope this is the right place to post this. I am trying to learn node.js and i am really struggling to get going. I have a mysql database hosted with ionos and i am trying to just start with a connection. I have the following which is the connection file and i am running it from the command line. var mysql = require('mysql'); var con = mysql.createConnection({ host: "xxxxxxx.hosting-data.io", user: "xxxxx", password: "xxxxx" }); con.connect(function(err) { if (err) throw err; console.log("Connected!"); }); I am getting the error: ❯ node db_conn.js /Users/xxxxxxx/Documents/xxxx/Sites/Node/first/db_conn.js:11 if (err) throw err; ^ Error: getaddrinfo ENOTFOUND xxxxxx.hosting-data.io at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) -------------------- at Protocol._enqueue (/Users/xxxx/Documents/xxxx/Sites/Node/first/node_modules/mysql/lib/protocol/Protocol.js:144:48) at Protocol.handshake (/Users/xxxx/Documents/xxxx/Sites/Node/first/node_modules/mysql/lib/protocol/Protocol.js:51:23) at Connection.connect (/Users/xxxx/Documents/xxxx/Sites/Node/first/node_modules/mysql/lib/Connection.js:116:18) at Object.<anonymous> (/Users/xxxx/Documents/xxxx/Sites/Node/first/db_conn.js:10:5) at Module._compile (node:internal/modules/cjs/loader:1267:14) at Module._extensions..js (node:internal/modules/cjs/loader:1321:10) at Module.load (node:internal/modules/cjs/loader:1125:32) at Module._load (node:internal/modules/cjs/loader:965:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) at node:internal/main/run_main_module:23:47 { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'xxxxx.hosting-data.io', fatal: true } Node.js v20.0.0 I appreciate this may be difficult to work on and i am sure there is info needed that i have not supplied but i am really struggling to get set up to work. If anyone can help or can suggest resources to help me that would be very much apprecitated. Thanks, As always. Edited April 22, 2023 by requinix redacting another instance of the domain name Quote Link to comment https://forums.phpfreaks.com/topic/316190-node-connection-to-mysql-database/ Share on other sites More sharing options...
requinix Posted April 22, 2023 Share Posted April 22, 2023 E NOT FOUND. Means the domain name doesn't exist. Check again what you're supposed to be using. Quote Link to comment https://forums.phpfreaks.com/topic/316190-node-connection-to-mysql-database/#findComment-1607615 Share on other sites More sharing options...
ahmedarain24 Posted June 1, 2023 Share Posted June 1, 2023 Based on the error message you provided, it seems that the hostname xxxxxxx.hosting-data.io cannot be resolved. This could be due to a few potential reasons: Incorrect hostname: Please double-check that the hostname you are using is correct. Ensure there are no typos and that the hostname corresponds to the correct database server provided by ionos. Network or DNS issues: The error ENOTFOUND suggests that the hostname cannot be found. This could be caused by network connectivity issues or DNS resolution problems. Ensure that your network connection is stable and try running the code again. You can also try using a different network or DNS server to see if that resolves the issue. Firewall or security restrictions: It's possible that there are firewall rules or security restrictions in place that prevent your Node.js application from accessing the specified hostname or port. Check if there are any network-level restrictions in your environment, such as firewall settings, that might be blocking the connection. Additionally, make sure you have installed the mysql package by running npm install mysql in your project directory. This command installs the MySQL driver for Node.js, which is necessary for establishing a connection with the MySQL database. If you continue to experience issues, it might be helpful to consult with your hosting provider (ionos) for further assistance and ensure that you have the correct hostname, port, username, and password for connecting to the MySQL database. Quote Link to comment https://forums.phpfreaks.com/topic/316190-node-connection-to-mysql-database/#findComment-1609323 Share on other sites More sharing options...
Zane Posted June 2, 2023 Share Posted June 2, 2023 The default port number is 3306. Is this port open? Is it even using 3306? It being your mysql server. Quote Link to comment https://forums.phpfreaks.com/topic/316190-node-connection-to-mysql-database/#findComment-1609360 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.