Issue connecting to servers within the designated MongoDB Atlas Cluster has caused a mongoDB error

const mongoose = require('mongoose');

mongoose.connect('mongodb://DATABASE_LOGIN1:[MyPass]@mee6copycluster-shard-00-00.r86qy.mongodb.net:27017/djsdashboard/?authSource=admin', {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

Error :

UnhandledPromiseRejectionWarning: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist

I am facing this issue and need assistance in resolving it. If you require additional information, please specify!

The error message obtained when using mongodb+srv://DATABASE_LOGIN1:[MyPass]@mee6copycluster-shard-00-00.r86qy.mongodb.net/admin?retryWrites=true&w=majority is as follows:

(node:7288) UnhandledPromiseRejectionWarning: Error: querySrv ENOTFOUND _mongodb._tcp.mee6copycluster-shard-00-00.r86qy.mongodb.net
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:202:19)
(node:7288) 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(). (rejection id: 1)
(node:7288) [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.

Answer №1

Dealing with a similar problem, I managed to solve it by clicking on the "Allow access from anywhere" option within the "Network Access" section of my MongoDB dashboard.

This issue may arise from connections through VPNs or proxies.

After doing this, you should now be able to connect to the server and port you designated.

Answer №2

Issue Resolved :

mongoose.connect('mongodb://DATABASE_LOGIN1:[MyPass]@mee6copycluster-shard-00-00.r86qy.mongodb.net:27017,mee6copycluster-shard-00-01.r86qy.mongodb.net:27017,mee6copycluster-shard-00-02.r86qy.mongodb.net:27017/djsdashboard?ssl=true&replicaSet=atlas-5r6qbu-shard-0&authSource=admin&retryWrites=true&w=majority', {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

Problem resolved successfully

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Javascript only select values from the initial row of the table

I have a database that I am using to populate a table with results. To interact with these results, I utilize JavaScript in addition to PHP for retrieving values from the database and displaying them in the table. <table id="datatable" class="table tab ...

Shadows in Three.js cascading onto clear surfaces with a low-resolution twist

Here's the problem I'm facing: I want to remove the shadows on the text but changing the shadowMap resolution doesn't seem to have any effect. This is the code snippet responsible for creating the mesh: var materialArray_Flying = [ ...

The output is consistently null

I'm encountering an issue with my implementation of the GCD function using recursion. Whenever I try to return a value, it always comes back as undefined. However, when I use console.log(value), it displays correctly on the screen. Below is the code ...

Exploring the differences between arrays and objects provided by users

I am working on a functionality that involves comparing user input with predefined usernames and passwords. Here is what I have so far: var sys = { users: [ {user: 'user1', pass: 'qwerty'}, {user: 'Ragnar&apos ...

Is it possible for API calls and database queries to create a bottleneck? Exploring the impact of Node.js and

Our frontend is built with React and the backend utilizes Node.js. At the moment, we are storing carts for unregistered users in MongoDB using sessions (with express-session and connect-mongo). In our frontend, I am currently making an API call every tim ...

Is there a way to set an antd checkbox as checked even when its value is falsy within an antd formItem?

I'm currently looking to "invert" the behavior of the antd checkbox component. I am seeking to have the checkbox unchecked when the value/initialValue of the antD formItem is false. Below is my existing code: <FormItem label="Include skills list ...

Incorporating Javascript into HTML

I have developed a script to randomly change the size of an element, but I am struggling to understand how to incorporate it using HTML or iframe code for randomization. <script type="text/javascript"> var banner1 = ["728", "90"]; var banne ...

"Although both jQuery and PHP are capable of setting the element attribute, it is only PHP that functions successfully

I have been trying to set an element attribute to adjust the range of a slider. Initially, I used ajax to fetch data from a php file and assign it to the attribute. The slider looked good with the value but unfortunately, it wasn't functioning as expe ...

Struggling with getting my Vue-CLI app deployed on Heroku

After diligently following all the steps outlined in this tutorial: https://codeburst.io/quick-n-clean-way-to-deploy-vue-webpack-apps-on-heroku-b522d3904bc8 I encountered an error message when checking my app at: The error indicated: Method Not Allowed ...

Exporting a JavaScript chart to an Excel file using Highcharts

Trying to export a JavaScript chart (HighCharts) into an Excel file has been challenging. The chart, rendered in a div, does not carry over the HTML and CSS formatting that the JavaScript generates, resulting in plain text without style. I have attempted ...

Prevent displaying page confirmation prompts when a user clicks on hyperlinks

One way to display a confirmation message when a user tries to leave the current page is by using this method: window.addEventListener("beforeunload", function (e) { var confirmationMessage = "Are you sure you want to leave?"; ...

Determining the lowest and highest values for a slider's range

I am looking to extract the minimum and maximum values from a price range. Here is the code snippet for reference: http://jsfiddle.net/dhana36/b453V/2/ Currently, I have one input field that controls both minimum and maximum values. However, I would pref ...

The error caught was an 'Uncaught TypeError: Undefined property 'setRGB' cannot be read'

I've been diving into webgl tutorials on udacity, but I've hit a snag. In the examples they use material.ambient for MeshLambertMaterial, which is working fine. However, when I tried to implement a basic cube from scratch using MeshLambertMateri ...

How is it that cross-domain scripting is able to occur with local files on a smartphone or tablet?

My Experiment: To test cross-site scripting (XSS), I set up an index.html file with a xss.js script that utilized the jQuery.get() function. After opening the index.html in various browsers (Firefox, Chrome, IE, and Opera), I attempted to trigger an ajax ...

Retrieving specific values from MongoDB objects using filters and searches

In my MongoDB database, I am working with documents that have a unique structure: { "_id": { "$oid": "570794ee453b02a0001000001" }, "fields_data": { "572999c241f1590001000005": "Chicago&q ...

javascript utilizing the canvas feature to resize and add graphics to an image

Is it possible to leverage Canvas for drawing over images that have been downloaded by users, all while adjusting the scale? For instance: User uploads an image Starts drawing on the image Zooms out and continues adding more drawings All modifications ...

Tips for creating emissiveMap lighting exclusively in dimly lit spaces using three.js

Using three.js, I am able to render the earth with textures and add an emissive texture for city lights. However, I am facing a problem where even the light areas of the earth emit city lights. For example: https://i.sstatic.net/hZ1Cr.png Is there a way ...

Warning in Next.js: When utilizing conditional rendering, the server HTML is expected to have a corresponding <div> inside another <div>

Although similar questions have been asked on various platforms like Google, none seem to provide answers that align with my specific situation. Essentially, my goal is to have a different search bar displayed in the header based on the page I am currentl ...

Is the Ajax DataType response JSON showing as "OK" but the output is blank?

So, I'm facing a challenge here. I have a basic jQuery Ajax request that isn't working when I set the DataType to "JSON". var form_data = { "id": msg, "token": token }; $.ajax({ type: 'POST', url: "ajax.php", ...

Moving from the center to the bottom-right with a CSS transition

I have a specific requirement where I need the container to cover the entire page and shrink when clicked, with an animation. Currently, I am using CSS transition to animate the container shrinking towards the top: The container shrinks slowly to the sp ...