Connect MongoDB (AWS) from Local Machine using WinSCP and MongoDB Compass
Last Updated :
01 Mar, 2024
Pre-requisite: AWS and MongoDB
In this article, we are going to connect to the Mongo database of the AWS Ubuntu Server instance using WinSCP and learn how to get connected to the server from your local machine using MongoDB Compass.Â
If you haven’t installed a MongoDB server in your AWS EC2 instance then follow the steps present in this article and create a mongo dB server in your AWS account. Before launching the AWS instance download the key pair of the instance for future authentication purposes. If you haven’t created one, go to services and search for Key pair and create a Key pair and download the .ppk file.

Â
Download and Keep the file in a secure place because it is a one-time downloadable file. This file can be used as a secure password file to connect to the server.
Tools Required:
WinSCP:
WinSCP is a free and open-source SFTP, FTP, WebDAV, and SCP client for Microsoft Windows. It allows users to transfer files between a local and a remote computer using various protocols, such as FTP, FTPS, SCP, SFTP, or WebDAV.
WinSCP is a popular choice for transferring files between a local computer and a remote server, especially when the server is running the Linux operating system. It has a user-friendly graphical interface and supports various advanced features, such as file synchronization and script execution.
In addition to file transfer, WinSCP can also be used to edit files directly on the remote server, or to browse and manage the file system on the server. It also includes a built-in text editor that allows users to edit files directly on the server without the need to download and upload them.
WinSCP is available as a standalone application and as a plugin for other applications, such as Microsoft Visual Studio. It is licensed under the GNU General Public License.
Connecting To Server:
Step 1: Installing WinSCP to get connected to the files present in the server we will be making use of WinSCP. Â We can transfer files and data to our server using WinSCP.
Step 2: Create a new Session in WinSCP for this open WinSCP and click on create a new session with protocol as SFTP. In the Hostname field get the Public IPv4 address of your AWS Instance and paste it there. The Port number will be 22 by default. In the User name field enter the username of your choice. Leave the password empty.

Â
Now browse to advanced settings and go to authentication and upload the .ppk file which we downloaded earlier while creating Key Pair in AWS and login into the system.

Â
Now our WinSCP is connected to our AWS Server.
Connect to the Server Database Using MongoDB Compass:
Step 1: Download and Install MongoDB compass. Select the latest version and Download the MSI file instead of the zip file. If we try to connect to our AWS instance from MongoDB compass we will get a timeout error because before accessing the instance we need to make the server globally available.
Step 2: Open WinSCP and click on “Open Session in PuTTY“. Now a PuTTY terminal will be opened. Set Mongo to access globally. Use the command below and modify the file /etc/mongod.conf details as below.
$ sudo vim /etc/mongod.conf
net:
port: 27017
bindIp: 0.0.0.0

Â
Step 3: Now restart the server using the below command
$ sudo service mongod restart
Step 4: Now go to the amazon instance and go to security details in AWS and click on Edit Inbound rules and one more rule for MongoDB port. Add an inbound rule with the following configurations.
- Type: All TCP
- Port range: 0 – 65535 (Because mongodb uses 27017 port)
- Source: Anywhere IPv4

Step 5: Now open Mongodb compass and click on the new connection and edit the connection string as follows “mongodb://Your_IPV4_IPAddress:27017/” and click on connect. Now you can access your AWS MongoDB server from your local machine.

Similar Reads
Connect MongoDB Atlas Cluster to MongoDB Compass
MongoDB Compass is a free GUI for MongoDB. We might want to connect MongoDB Atlas Cluster to MongoDB Compass to take benefit of the GUI model for database administration. By connecting MongoDB Atlas, the fully managed cloud database service, to MongoDB Compass, developers can easily interact with th
5 min read
How to Connect Mongo DB with AWS using ATLAS?
The MongoDB Atlas provides the Application deployment solution by MongoDB hosting on AWS. MongoDB Atlas handles operational tasks such as backups, updates, and security configurations. There are many ways to connect MongoDB with AWS depending on specific use cases and requirements: MongoDB Atlas (Fu
5 min read
Connect MongoDB with Node App using MongooseJS
The process of integrating MongoDB, a NoSQL database, with a Node.js application using MongooseJS, a MongoDB object modelling tool designed to work in an asynchronous environment. Prerequisites:NodejsnpmMongoDBMongooseJSSteps to connect MongoDB with Node AppFollowing are the steps to connect MongoDB
4 min read
MongoDB Compass vs MongoDB Atlas
MongoDB is a widely-used NoSQL database known for its flexibility, scalability, and high performance. Two key tools associated with MongoDB are MongoDB Compass and MongoDB Atlas, each serving distinct purposes. While MongoDB Compass provides a graphical interface for managing databases locally, Mong
5 min read
How to fetch single and multiple documents from MongoDb using Node.js ?
MongoDB, the most popular NoSQL database, is an open-source document-oriented database. The term âNoSQLâ means ânon-relationalâ. It means that MongoDB isnât based on the table-like relational database structure but provides an altogether different mechanism for storage and retrieval of data. This fo
2 min read
How to Connect Node.js To MongoDB Atlas Using Mongoose?
MongoDB Atlas is a cloud-based database service that offers robust features and scalability for managing our data. Here we will use Express.js for the server framework and Mongoose for interacting with MongoDB. And also we use the Ejs for our front end to render the simple HTML form. In this tutoria
6 min read
Login form using Node JS and MongoDB
Follow these simple steps to learn how to create a login form using NodeJS and MongoDB. NodeJS login form allows users to log in to the website after they have created their account using the signup form. We will be using the following technologies: NodeJS & Express â Backend server and routingM
4 min read
How to Connect MongoDB Atlas Cluster From an Application?
To connect your application to MongoDB Atlas, a cloud-based, fully-managed NoSQL database, you'll first need to set up a MongoDB Atlas cluster and configure a few essential settings. MongoDB Atlas offers a secure, scalable platform to manage your database without the hassle of manual maintenance, ba
7 min read
How to Connect to Amazon Linux Instance from Windows Client Operating System using PUTTY?
In this article, we will learn how to connect the Amazon Linux instances from Windows client operating system. For this we will be performing the following operations: Create a Linux instance in Amazon AWS.Using putty application connect to the Linux instance from the windows client operating system
2 min read
Install MongoDB Compass on Windows
MongoDB Compass is a powerful graphical user interface for MongoDB which is designed to simplify database management. It offers features like easy querying, index visualization, an aggregation pipeline builder and schema and structure analysis. In this article, we will learn How to Install MongoDB C
5 min read