I am trying to run my application on firebase function and even though the deployment has been successfully completed,On running the app I am getting the error not found. Additionally when running on localhost there is no problem.
On further investigation I am getting the below logs which I think points to mongodb connection issue. Hence if someone can please help me resolve this problem.
let me know if you require any further information from my end.
(using robo3T)
mongoose.js
const mongoose = require('mongoose')
mongoose.connect('mongodb://127.0.0.1:27017/user', {
useNewUrlParser: true,
})
mongoose.connection.on("error", err => {
console.log("err", err)
})
mongoose.connection.on("connected", (err, res) => {
console.log("mongoose is connected")
})
firebase function:log
2022-09-30T14:11:28.461675Z ? app: err MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
2022-09-30T14:11:28.461717Z ? app: at NativeConnection.Connection.openUri (/workspace/node_modules/mongoose/lib/connection.js:824:32)
2022-09-30T14:11:28.461730Z ? app: at /workspace/node_modules/mongoose/lib/index.js:380:10
2022-09-30T14:11:28.461739Z ? app: at /workspace/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5
2022-09-30T14:11:28.461747Z ? app: at new Promise (<anonymous>)
2022-09-30T14:11:28.461757Z ? app: at promiseOrCallback (/workspace/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)
2022-09-30T14:11:28.461766Z ? app: at Mongoose._promiseOrCallback (/workspace/node_modules/mongoose/lib/index.js:1233:10)
2022-09-30T14:11:28.461775Z ? app: at Mongoose.connect (/workspace/node_modules/mongoose/lib/index.js:379:20)
2022-09-30T14:11:28.461783Z ? app: at Object.<anonymous> (/workspace/db/mongoose.js:4:10)
2022-09-30T14:11:28.461792Z ? app: at Module._compile (node:internal/modules/cjs/loader:1126:14)
2022-09-30T14:11:28.461801Z ? app: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10) {
2022-09-30T14:11:28.461809Z ? app: reason: TopologyDescription {
2022-09-30T14:11:28.461817Z ? app: type: 'Unknown',
2022-09-30T14:11:28.461825Z ? app: servers: Map(1) { '127.0.0.1:27017' => [ServerDescription] },
2022-09-30T14:11:28.461832Z ? app: stale: false,