Connecting to MongoDB in Node.js

⭕ Overview

In this video, we’ll make a connection to a MongoDB database using the mongodb module in Node.js.

Note: For local MongoDB databases, use the IP address “” instead of “localhost” because Node.js 18 and up prefer IPv6 addresses. This means, on many machines, Node.js will resolve “localhost” to the IPv6 address “::1” and it might be unable to connect, unless the mongodb instance is running with ipv6 enabled.

Verified by MonsterInsights