Error connecting to Mongo database: connection 5

Can anyone shed light on what might be causing this issue?

{ MongoNetworkError: connection 5 to magicalcreature-shard-00-00-jfi8q.mongodb.net:27017 closed

Everything runs smoothly on my PC and all connections are working fine. However, when I deploy it on Heroku, an error pops up. The code on GitHub is identical except for the fact that I used process.env.MONGOD instead of the original connection string. Here's a glimpse of the connection string:

mongodb+srv://AlwaysRejected:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2353425050544c5147634e42444a40424f40514642575651460e49454a1b520d4e4c4d444c4740cd4d4657">[email protected]</a>/test?retryWrites=true

Answer №1

While browsing through similar questions, I stumbled upon this issue that was posted 4 months ago. Even though it's an old post, I thought of sharing the solution that worked for me just in case someone else encounters the same problem.

The issue I faced was related to mongodb requiring a whitelist of IPs. Since Heroku does not have a static IP unless you set up an enterprise private space, I had to whitelist all IPs using 0.0.0.0/0 as a workaround.

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

The animation triggered by scrolling is not functioning on this element

I'm currently attempting to add a scroll animation to my section1 element, but for some reason, it's not working. This is puzzling to me because I've successfully implemented the same scroll code on another element without any issues. The on ...

Enhancing the smoothness of parallax scrolling

My header is going to be twice the height of the viewport. I added a simple parallax effect so that when you scroll down, it reveals the content below. However, I'm experiencing flickering in the content as I scroll, possibly due to the CSS style adju ...

Is there a way to verify if I am using yarn link properly?

Is there a way for me to determine if my locally linked package is being utilized instead of the remote version? Should it be visible on the development server of my local package? ...

React List not showing Image

I have developed a React component that showcases images in an array. Here is the snippet of the source code: import React from "react"; import styled from "styled-components"; import burgerTop from "../../assets/images/burgerTop.png"; import burgerBottom ...

Struggling with JavaScript conditional statements

Currently, I am in the process of creating a login and registration panel using jQuery and PHP. Essentially, if there are any errors during registration, it sets certain form errors, redirects back to the registration page, the JavaScript identifies these ...

Transform a MongoCursor obtained from the ->find() method into an array

$comedy = $collection->find(); Is there a way to change $comedy into an array format? ...

Issues with Express js routes in MEAN stack causing unexpected behavior

I've recently started working with express/mongoose and I'm having trouble understanding why my routes are not functioning correctly in the MEAN stack. On my application, I have a general offer route '/offers' and then specific offer r ...

How to utilize Vue.js 3, Axios, and Express to showcase data retrieved from an array or

Trying to display a single post fetched from an express API using Vue has been challenging. The issue lies in the fact that the values declared in the template for post.title & post.body are not being displayed as expected when accessing post.value. ...

Filtering an array of parent elements in Javascript based on a specific value found in

Trying to filter data from a 3-layer array based on child array values. Making progress but hitting a roadblock at the end. { "id": 1, "grandparent": "Timmy", "parents": [ { "id&q ...

Bootstrap tab toggling with checkbox

I'm attempting to create tabs with the ability to include checkboxes, but when using data-toggle="tabs", the checkbox functionality seems to be disabled. Here is the link to my fiddle. Is there a solution to make the checkbox work within the tab tog ...

The Google Maps JavaScript API is displaying a map of China instead of the intended location

After multiple attempts, I am still facing an issue with setting up the Google Map on my website. Despite inputting different coordinates, it consistently shows a location in China instead of the intended one. Here is the code snippet that I have been usin ...

JavaScript Dynamic Array for Generating GoogleChart JSON Data

I am attempting to create a line chart using Google Charts ( ), but I am struggling with formatting the array for the chart. The required array format is as follows : var data = google.visualization.arrayToDataTable([ ['Year', 'Sales&ap ...

Error encountered in React: Unable to access property of splice as it is undefined

As I am still getting acquainted with React/JS, I am currently navigating through the process of developing a mobile website. My main goal is to incorporate a delete function without the use of a button. My approach involves utilizing a long-press event, a ...

What methods work best for retrieving non-API data in Next.js when deploying on Vercel?

Before rendering my application, I am working on fetching my data. Luckily, Next.js offers a method called getStaticProps() for this purpose. Currently, I am utilizing the fs module to retrieve data from a json file in my local directory. export async fun ...

Automatically arranging documents in ascending order in MongoDB

I am currently dealing with a list of documents stored in a database collection. These documents are arranged in a specific order which can be changed using a drag-and-drop feature on the front-end. The order field within each document is used to sort them ...

Sequence of text array contains a gap

I'm struggling with a simple array text sequence where A, B, and C need to show for 2500ms each before cycling back through. Currently, there is a blank frame displayed for 2500ms that I can't seem to get rid of. Does anyone have a solution to ...

What is the behavior of the JavaScript event loop when a Promise's resolution is tied to setTimeout?

console.log('1') setTimeout(() => { console.log('2') }, 0) function three() { return new Promise(resolve => { setTimeout(() => { return new Promise(resolve => resolve('3')) },0) ...

Using regular expressions in Javascript to extract decimal numbers from a string for mathematical operations

I'm currently working on a Vue method where I extract information from a WordPress database. The data retrieved sometimes contains unnecessary text that I want to filter out. Using the prodInfo variable, the input data looks something like this: 2,5k ...

Utilizing aria-expanded="true" for modifying a CSS attribute: A simple guide

I am looking to utilize aria-expanded="true" in order to modify a css property such as an active class : <li class="active"> <a href="#3a" class="btn btn-default btn-lg" data-toggle="tab" aria-expanded="true"> <span class="networ ...

How to Use Javascript to Dynamically Calculate Table Heading Widths (Assigning PHP Data to Javascript Variables)

I'm currently working on a project to create a dynamic table with headings that are split equally across the required number of columns (stored in the PHP variable "$numberofcolumns"). Could someone assist me in adding the necessary code to calculate ...