node.js – Node Js, MongoDB deployment
when i try to deploy my app and connect to the DB, this happens on render.com.
It seems that my app is trying to connect to local db, but I do not know how to change that.
Nov 14 10:19:09 PM Failed to connect to the database
Nov 14 10:19:09 PM MongoParseError: Invalid scheme, expected connection string to start with “mongodb://” or “mongodb+srv://”
Nov 14 10:19:09 PM at new ConnectionString (/opt/render/project/src/node_modules/mongodb-connection-string-url/lib/index.js:86:19)
Nov 14 10:19:09 PM at parseOptions (/opt/render/project/src/node_modules/mongodb/lib/connection_string.js:200:17)
Nov 14 10:19:09 PM at new MongoClient (/opt/render/project/src/node_modules/mongodb/lib/mongo_client.js:45:63)
Nov 14 10:19:09 PM at /opt/render/project/src/node_modules/mongodb/lib/mongo_client.js:236:28
Nov 14 10:19:09 PM at maybeCallback (/opt/render/project/src/node_modules/mongodb/lib/utils.js:337:21)
Nov 14 10:19:09 PM at Function.connect (/opt/render/project/src/node_modules/mongodb/lib/mongo_client.js:234:42)
Nov 14 10:19:09 PM at Object.connectToDatabase (/opt/render/project/src/data/database.js:11:38)
Nov 14 10:19:09 PM at Object. (/opt/render/project/src/app.js:50:4)
Nov 14 10:19:09 PM at Module._compile (internal/modules/cjs/loader.js:1068:30)
Nov 14 10:19:09 PM at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
Nov 14 10:19:39 PM (node:65) UnhandledPromiseRejectionWarning: Error: Error connecting to db: connect ECONNREFUSED 127.0.0.1:27017
Nov 14 10:19:39 PM at /opt/render/project/src/node_modules/connect-mongodb-session/index.js:88:17
Nov 14 10:19:39 PM at /opt/render/project/src/node_modules/mongodb/lib/utils.js:348:66
Nov 14 10:19:39 PM (Use node --trace-warnings ...
to show where the warning was created)
Nov 14 10:19:39 PM (node:65) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
Nov 14 10:19:39 PM (node:65) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Not sure how to make my app not connecting to local db
Read more here: Source link