Connect MongoDB (AWS) from Local Machine using WinSCP and MongoDB Compass
Last Updated :
23 Jul, 2025
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
DevOps Tutorial DevOps is a combination of two words: "Development" and "Operations." Itâs a modern approach where software developers and software operations teams work together throughout the entire software life cycle.The goals of DevOps are:Faster and continuous software releases.Reduces manual errors through a
7 min read
Introduction
What is DevOps ?DevOps is a modern way of working in software development in which the development team (who writes the code and builds the software) and the operations team (which sets up, runs, and manages the software) work together as a single team.Before DevOps, the development and operations teams worked sepa
10 min read
DevOps LifecycleThe DevOps lifecycle is a structured approach that integrates development (Dev) and operations (Ops) teams to streamline software delivery. It focuses on collaboration, automation, and continuous feedback across key phases planning, coding, building, testing, releasing, deploying, operating, and mon
10 min read
The Evolution of DevOps - 3 Major Trends for FutureDevOps is a software engineering culture and practice that aims to unify software development and operations. It is an approach to software development that emphasizes collaboration, communication, and integration between software developers and IT operations. DevOps has come a long way since its in
7 min read
Version Control
Continuous Integration (CI) & Continuous Deployment (CD)
Containerization
Orchestration
Infrastructure as Code (IaC)
Monitoring and Logging
Microsoft Teams vs Slack Both Microsoft Teams and Slack are the communication channels used by organizations to communicate with their employees. Microsoft Teams was developed in 2017 whereas Slack was created in 2013. Microsoft Teams is mainly used in large organizations and is integrated with Office 365 enhancing the feat
4 min read
Security in DevOps