0

i have a node application that is duplicated both on the server (digital ocean) as well as my local machine. im trying to configure the local version so that i can use it as a 'sandbox' environment to make changes and edits before i push the update to the live application on the server.

the databaseconnection.js file contains the following.

const mysql = require('mysql');

function getConnection() {
    return mysql.createPool({
        connectionLimit: 100,
        host: 'ipaddress',
        port: 3306,
        user: 'forge',
        password: 'password',
        database: 'mydatabase',
        multipleStatements: true
        
    });
}

module.exports = getConnection();

when i access the node application that is stored on the DO server, everything run fine, however, when i try to run it from my localhost environment, i get the following error.

Error: connect ETIMEDOUT
    at PoolConnection.Connection._handleConnectTimeout (C:\MAMP\htdocs\WIGHTcloudDEV\node_modules\mysql\lib\Connection.js:409:13)
    at Object.onceWrapper (events.js:286:20)
    at Socket.emit (events.js:198:13)
    at Socket._onTimeout (net.js:442:8)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
    --------------------
    at Protocol._enqueue (C:\MAMP\htdocs\WIGHTcloudDEV\node_modules\mysql\lib\protocol\Protocol.js:144:48)
    at Protocol.handshake (C:\MAMP\htdocs\WIGHTcloudDEV\node_modules\mysql\lib\protocol\Protocol.js:51:23)
    at PoolConnection.connect (C:\MAMP\htdocs\WIGHTcloudDEV\node_modules\mysql\lib\Connection.js:116:18)
    at Pool.getConnection (C:\MAMP\htdocs\WIGHTcloudDEV\node_modules\mysql\lib\Pool.js:48:16)
    at Pool.query (C:\MAMP\htdocs\WIGHTcloudDEV\node_modules\mysql\lib\Pool.js:202:8)
    at Strategy.passport.use.OutlookStrategy [as _verify] (C:\MAMP\htdocs\WIGHTcloudDEV\config\passport-setup.js:58:18)
    at C:\MAMP\htdocs\WIGHTcloudDEV\node_modules\passport-oauth2\lib\strategy.js:202:24
    at Request._callback (C:\MAMP\htdocs\WIGHTcloudDEV\node_modules\passport-outlook\lib\strategy.js:157:5)
    at Request.self.callback (C:\MAMP\htdocs\WIGHTcloudDEV\node_modules\request\request.js:185:22)
    at Request.emit (events.js:198:13)

i slightly remember doing something with either ssh2 or tunnel forwarder in the past that pertained to this issue but i cant find any of my old files nor can i find anything online that clearly shows what im missing.

wmunsell
  • 23
  • 5
  • Looks like you don't have access to that IP address from your localhost. Try to connect using a MySQL client like DBeaver or Mysql Workbench. – Disturb Aug 12 '20 at 19:36
  • @Disturb i am connected to the database using MySQL Workbench with no issues. i have copied all of the information from my connection settings to the databaseconnection.js file. the only thing that is missing is the ssh key file. how would i implement that within my application? – wmunsell Aug 12 '20 at 19:39
  • `host: 'ipaddress',` is that `127.0.0.1`? or maybe `localhost`? Or something else – RiggsFolly Aug 12 '20 at 19:44
  • @RiggsFolly no, that is the ip address to the server, however, i have tried multiple (server ip, localhost, and 127.0.0.1). still nothing – wmunsell Aug 12 '20 at 19:46
  • Dreaming up hosts is not the idea! Where is the instance of MySQL that you are trying to connect to? Is it on this PC or another PC – RiggsFolly Aug 12 '20 at 19:49
  • @RiggsFolly i agree, the MySQL instance is located on Digital Ocean server. – wmunsell Aug 12 '20 at 19:52
  • Then go to your admin panel and find the ip address – RiggsFolly Aug 12 '20 at 19:52
  • Then check that `user: 'forge',` Is allowed to connect from a remote IP specifically yours – RiggsFolly Aug 12 '20 at 19:53
  • Maybe this answer can hep you https://stackoverflow.com/questions/24687932/node-js-connecting-through-ssh – Disturb Aug 12 '20 at 20:14

0 Answers0