Waiting on 27017 After Installation

Tahseen Tauseef Feb 02, 2024
  1. How to Install MongoDB
  2. MongoDB waiting for connections on port 27017 Error
Waiting on 27017 After Installation

MongoDB is a document-oriented NoSQL database for storing large amounts of data. MongoDB employs collections and documents instead of tables and rows, unlike typical relational databases.

MongoDB’s basic data unit is key-value pairs used to create documents. Collections are similar to relational database tables in that they include sets of documents and functions.

MongoDB is a database that first gained popularity in the mid-2000s.

This MongoDB article will teach how to fix the MongoDB waiting for connections on port 27017. This error occurs for some users after installation.

To learn how to fix this error, you first need to install MongoDB on your computer.

How to Install MongoDB

This part of the article will explain how you can install MongoDB on your computer.

Download the MongoDB MSI Installer Package

Head over to this website and install the most recent version of MongoDB. Make sure MSI is selected as the package to be downloaded.

Install MongoDB With the Installation Wizard

Make sure you are logging in as a user with admin privileges. Then, double-click the .msi package you just downloaded in your downloads folder.

The installation wizard will be launched as a result of this. To begin the installation, click the Next button.

Accept the license agreement and move on to the next step. It will now prompt you to select the type of setup. Choose the Complete configuration option.

Next, select Run as Network Service user and take note of the data directory; you’ll need it later. You won’t require Mongo Compass, so uncheck it and go on to the next step.

To begin the installation, click the Install button. Finally, to complete the installation, click the Finish button.

Create the Data Folders to Store Databases

Using Explorer, navigate to your computer’s C Drive and create a new data folder. Make a new folder called db inside the data folder you just made.

Set Up Shortcuts for Mongo and Mongod

You need to set up MongoDB on the local system once the installation is complete. First, change the directory to your home directory with the following command in your Hyper terminal running Git Bash.

cd ~

Here, you will create a file called .bash_profile using the command below.

touch .bash_profile

Use the following command to open Vim’s newly created .bash profile.

vim .bash_profile

Enter the insert mode in Vim by hitting the I key on the keyboard. Then, in your Explorer, go to CProgram FilesMongoDBServer.

Now you will be able to see the MongoDB version.

Copy and paste the following code into Vim, replacing 4.0 with the version you see in Explorer.

alias mongod="/c/Program\ files/MongoDB/Server/4.0/bin/mongod.exe"
alias mongo="/c/Program\ Files/MongoDB/Server/4.0/bin/mongo.exe"

To save and leave Vim, press the Esc key on your keyboard to exit the insert mode and type the following command.

:wq!

Verify That Setup Was Successful

Close the current Hyper terminal and quit the application, then re-launch Hyper. In the Hyper Terminal, type the following command.

mongo --version

Once you’ve pressed the Enter button, you should see something like this:

waiting on connection

MongoDB has been successfully installed and configured on your computer.

If you see something that seems like the bash mongo command is not found, double-check all of the steps above and go over them again, ensuring there are no mistakes and that you haven’t missed any steps.

MongoDB waiting for connections on port 27017 Error

Sometimes after installation, MongoDB gives you the waiting for connections on port 27017 error. To get rid of this error, you will need to follow the following steps.

Start a CMD/Terminal/BashShell. Launch the MongoDB server by running mongod.exe, where the suffix d denotes daemon (i.e., server).

Observe the console message.

mongod --dbpath "c:/mongo/data"
......
2020-03-06T23:24:13.298-0700 I  NETWORK  [listener] Listening on 127.0.0.1
2020-03-06T23:24:13.300-0700 I  NETWORK  [listener] waiting for connections on port 27017
......

Start another CMD/Terminal/BashShell then launch the command-line client by running mongo.exe (without the suffix d for client).

mongo
MongoDB shell version v4.0.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
......
// show databases
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB

// show collections (documents)
> show collections

The waiting for connection message in the terminal indicates that MongoDB is running successfully. So you will leave it and open a new terminal for connection.

So through the help of this MongoDB article, you learned how to install MongoDB on your computer and get rid of the waiting for connections on port 27017 error after installation.

Related Article - MongoDB Installation