I’m trying to set up my website it’s already complete and it works locally on my computer but when I transferred it to a hosting site that uses cpanel. The contact page that uses Express as it’s backend wasn’t working. So I got access to the terminal and set up node js and all of the dependencies I am using through npm but I’ve run into this error concerning the connection to MongoDB I can’t figure out what to do.
Photo form listening at http://0.0.0.0:27017
(node:1021120) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(node:1021120) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [cluster0-shard-00-00-wf77h.mongodb.net:27017] on first connect [MongoNetworkError: connect ECONNREFUSED ip_address:27017]
at Pool.<anonymous> (/home/q75z8jpp645w/public_html/node_modules/mongodb/lib/core/topologies/server.js:433:11)
at emitOne (events.js:116:13)
at Pool.emit (events.js:211:7)
at createConnection (/home/q75z8jpp645w/public_html/node_modules/mongodb/lib/core/connection/pool.js:577:14)
at connect (/home/q75z8jpp645w/public_html/node_modules/mongodb/lib/core/connection/pool.js:1021:9)
at makeConnection (/home/q75z8jpp645w/public_html/node_modules/mongodb/lib/core/connection/connect.js:31:7)
at callback (/home/q75z8jpp645w/public_html/node_modules/mongodb/lib/core/connection/connect.js:247:5)
at TLSSocket.err (/home/q75z8jpp645w/public_html/node_modules/mongodb/lib/core/connection/connect.js:276:7)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:1021120) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejectinga promise which was not handled with .catch(). (rejection id: 1)
(node:1021120) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. Inthe future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I’ve tried various ways to remedy this but to no prevail. I figure it could be I don’t have mongodb in my path for the server but I wasn’t able to get access to add it so I didn’t try could that be it. If anyone has experience with mongodb and hosting websites your help would be greatly appreciated. Also I’m open to using a different database I just opted to use mongo for it’s simplicity.
So far i’ve been studying about how to make websites and webpages but I’ve never really encountered how to host these sites so when I made my website I wasn’t thinking how I could host it with it using nodejs/expressjs, mongodb, and even other modules such as handlebars and lightbox (which seem to be working).
2
Answers
Well, this seems pretty unfortunate turns out its most likely not possible. I'm glad I was able to learn more about how hosting an actual site works but it seems like I'm gonna have to try a different approach for saving data.
Reference: [https://serverfault.com/questions/260924/how-can-i-setup-mongodb-with-godaddy-shared-hosting][1]
If you are using mongo atlas service, there is a section called Network access on the left sidebar on your dashboard. You can check free access from anywhere and then the problem will be solved.
Actually mongo atlas put IP address constraints on incoming requests by default.