![]() I am in my learning phase and was looking forward to learn databases for backend but this has stopped me and i cannot go forward. restarting wsl mongo server as well as windows mongo server.Working on a local database is part of developing any web, desktop, or mobile application. If connecting fails on your machine, try using 127.0.0.1. This is the default port the MongoDB database server listens to the commands. This is the minimum needed to connect the myapp database running locally on the default port (27017). swapping localhost to 127.0.0.1 to 0.0.0.0 To connect your application with your local MongoDB database, you need to connect MongoDB on the localhost 27017 port.reinstalling everything(including wsl2).I have spend 4 hours searching on the for the solution trying everything When nothing worked i even stopped windows mongo services and tried to only run mongo server in wsl and it got connected with the mongodb compass but then also my code gave same error. MongoDB provides official packages for the graphical tool for Ubuntu and RHEL-based Linux distributions, as well as Windows and MacOS. Note MongoDB Atlas If you need to create a MongoDB host, consider using MongoDB Atlas. You can connect to a standalone, replica set, or sharded cluster host. ![]() This is my filesystem for the express app Step 1 Installing MongoDB Compass To use MongoDB Compass, you must install it on your local computer. On this page Considerations Connect Connect to Compass from the Command Line Advanced Connection Options This page outlines how to use MongoDB Compass to connect to a MongoDB host. MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017Īt _handleConnectionErrors (/home/tanjiro/Programming/WebD/MongoDb/fruitsDB/node_modules/mongoose/lib/connection.js:792:11)Īt NativeConnection.openUri (/home/tanjiro/Programming/WebD/MongoDb/fruitsDB/node_modules/mongoose/lib/connection.js:767:11)Īt runNextTicks (node:internal/process/task_queues:60:5)Īt listOnTimeout (node:internal/timers:540:9)Īt process.processTimers (node:internal/timers:514:7) home/tanjiro/Programming/WebD/MongoDb/fruitsDB/node_modules/mongoose/lib/connection.js:792 I got output Server is running on port 3000 The admin, config, and local are default databases and you shouldn't delete them. As soon as you click connect, Compass connects to your local server and shows information about the databases within and allow you to manage your data using the graphical user interface. This is the code const express = require('express') Ĭonst mongoDb = "mongodb://127.0.0.1:27017/shopDB"Ĭonsole.log("Server is running on port 3000") Click Connect to connect to the MongoDB server running on your machine. I make sure the mongo server was running by using sudo systemctl status mongod active services ![]() ![]() My code is simple and very basic i wanted to start mongoose for the first time in wsl using vscode ![]()
0 Comments
Leave a Reply. |