I deployed a next js
web application on to Azure Web App Service
, and want to use it to connect to existing remote database, however I am keep getting such error in the log stream:
2021-04-23T18:09:17.315942065Z Error: connect ECONNREFUSED 127.0.0.1:3306
2021-04-23T18:09:17.315993564Z at Query._callback (/home/site/wwwroot/.next/server/pages/api/getFromUrl.js:128:16)
2021-04-23T18:09:17.316000664Z at Query.Sequence.end (/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
2021-04-23T18:09:17.316013164Z at /node_modules/mysql/lib/Pool.js:205:13
2021-04-23T18:09:17.316017064Z at Handshake.onConnect (/node_modules/mysql/lib/Pool.js:58:9)
2021-04-23T18:09:17.316020764Z at Handshake.<anonymous> (/node_modules/mysql/lib/Connection.js:526:10)
2021-04-23T18:09:17.316025064Z at Handshake._callback (/node_modules/mysql/lib/Connection.js:488:16)
2021-04-23T18:09:17.316028764Z at Handshake.Sequence.end (/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
2021-04-23T18:09:17.316032364Z at Protocol.handleNetworkError (/node_modules/mysql/lib/protocol/Protocol.js:369:14)
2021-04-23T18:09:17.316035964Z at PoolConnection.Connection._handleNetworkError (/node_modules/mysql/lib/Connection.js:418:18)
2021-04-23T18:09:17.316039564Z at Socket.emit (events.js:315:20)
My db connection in the app is:
export const db = mysql.createPool({
host: 'abcd.efghosting.com',
port: 3306,
database: 'pwpush',
user: 'pwpush_user',
password: ....,
multipleStatements: true,
});
Not sure why it's trying to connect to 127.0.0.1:3306
I tried to open something like hybrid-connection to the database endpoint but that didn't work.