Skip to main content
Home/Blog/Cybersecurity/How to Install Metasploit Framework - Complete Installation Guide for 2025
Cybersecurity

How to Install Metasploit Framework - Complete Installation Guide for 2025

Step-by-step guide to installing Metasploit Framework on Linux, Windows, and macOS. Learn the proper installation methods, database configuration, common troubleshooting steps, and best practices for getting started with the world's most popular penetration testing framework.

By Inventive HQ Team•
How to Install Metasploit Framework - Complete Installation Guide for 2025

The fastest way to install Metasploit Framework depends on your platform: on Kali Linux it is already pre-installed (just run msfconsole); on supported Debian-based Linux distributions use Rapid7's installer script (msfinstall); and on Windows and macOS you download the signed installer package from the official Metasploit sites. After installing, you initialize the PostgreSQL database with msfdb init and verify the setup inside msfconsole by running db_status and version. Installation time depends on the platform and package downloads.

That is the summary an AI overview would give you. What it can't give you is the part that actually matters when the install goes sideways: which method is right for your situation, how to handle antivirus alerts during Windows installation, how to fix the "No database connection" error that trips up most beginners, and how to prove your install actually works before you rely on it. This guide walks all of that, per operating system, with a copy-paste command flow and a verification checklist.

⚠️ Authorization notice: Metasploit is a legitimate security tool, but only run it against systems you own or have explicit written authorization to test. Unauthorized use violates laws including the U.S. Computer Fraud and Abuse Act (CFAA) and its international equivalents. Practice on deliberately vulnerable targets like Metasploitable, not on anything you don't have permission to touch.

Which install method should I use?

Pick your row, run the command, and skip straight to that platform's section below. Kali is the recommended starting point for beginners — everything is pre-wired.

PlatformRecommended methodCore commandDatabase
Kali LinuxUsually pre-installedmsfconsole (update via apt upgrade metasploit-framework)PostgreSQL pre-configured; msfdb init if needed
Debian / UbuntuOfficial Rapid7 nightly installercurl .../msfinstall > msfinstall && chmod 755 msfinstall && ./msfinstallInstall PostgreSQL, then sudo msfdb init
Other LinuxCheck Rapid7's current support and distribution-specific package instructionsFollow the supported method for your distributionConfigure PostgreSQL if required
Windows 10/11Signed .msi from windows.metasploit.comRun installer as Administrator, then msfdb.bat initBundled PostgreSQL — no separate install
macOSSigned .pkg from osx.metasploit.comRun .pkg, then msfdb initInstall PostgreSQL via Homebrew

The one-line rule: if you are learning, use Kali Linux — the framework, Ruby, and PostgreSQL are already installed and integrated. If you must stay on your existing OS, use the official Rapid7 installer for that platform and never a third-party mirror (the installer runs with root/admin privileges).

The install-to-verify flow

Every platform follows the same four-stage sequence. Install the framework, set up the PostgreSQL database, launch the console, then confirm it works — don't skip the last stage.

Metasploit install and verification flow Four stages left to right: Install framework, Set up database with msfdb init, Launch msfconsole, and Verify with db_status and version. A marker travels along the path and each stage highlights in turn. Install to verify: the same four stages on every OS 1 Install msfinstall / .msi 2 Set up database msfdb init 3 Launch msfconsole 4 Verify db_status / version

What is Metasploit Framework?

Metasploit Framework is an open-source penetration testing platform developed by Rapid7. It provides security professionals with:

  • Exploit modules: Pre-built exploits for known vulnerabilities
  • Payloads: Code that executes on target systems (shells, Meterpreter, etc.)
  • Auxiliary modules: Scanners, fuzzers, and reconnaissance tools
  • Post-exploitation modules: Tools for maintaining access and gathering information
  • Encoders: Payload obfuscation to evade detection

Unlike the commercial Metasploit Pro version, Metasploit Framework is completely free and maintained by the security community.

System Requirements

Before installing Metasploit, ensure your system meets these requirements:

Minimum Requirements:

  • CPU, RAM, and disk: Allow enough capacity for the framework, database, modules, and your workload; check current package requirements for your platform.
  • Network: Internet connection for updates and module downloads

Software Dependencies:

  • Ruby: Use the version required by your installation method (bundled in some installers)
  • PostgreSQL: Use a version supported by your Metasploit package for database features
  • Git: For installing from source (optional)

Installing Metasploit on Kali Linux

Kali Linux is the most popular platform for Metasploit, as it comes pre-installed with the framework and all dependencies.

Method 1: Using Pre-installed Metasploit (Kali 2020.1+)

Metasploit is commonly included with Kali Linux; verify it on your image. To verify and update:

# Check if Metasploit is installed
msfconsole --version

# Update Metasploit to latest version
sudo apt update && sudo apt upgrade metasploit-framework -y

Method 2: Fresh Installation via APT

If Metasploit isn't installed or you need a clean installation:

# Update package lists
sudo apt update

# Install Metasploit Framework
sudo apt install metasploit-framework -y

# Install PostgreSQL (required for database)
sudo apt install postgresql postgresql-contrib -y

Setting Up the Database on Kali Linux

Metasploit requires a PostgreSQL database for storing host information, scan results, and credentials:

# Start PostgreSQL service
sudo systemctl start postgresql

# Enable PostgreSQL to start on boot
sudo systemctl enable postgresql

# Initialize the Metasploit database
sudo msfdb init

# Verify database connection
msfconsole -q

Inside msfconsole, run db_status to verify the connection.

db_status

You should see output confirming: [*] Connected to msf. Connection type: postgresql.

Installing Metasploit on Ubuntu/Debian Linux

For non-Kali Debian-based systems, use the official Rapid7 installer:

Step 1: Download and Run the Installer Script

# Download the official installer
curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall

# Make it executable
chmod 755 msfinstall

# Run the installer (requires sudo)
sudo ./msfinstall

This script will:

  • Add Rapid7's GPG key to your system
  • Add the Metasploit repository to your package sources
  • Install Metasploit Framework and dependencies
  • Set up the correct permissions

Step 2: Install and Configure PostgreSQL

# Install PostgreSQL
sudo apt install postgresql postgresql-contrib -y

# Start PostgreSQL service
sudo systemctl start postgresql
sudo systemctl enable postgresql

# Initialize Metasploit database
sudo msfdb init

Step 3: Verify Installation

# Launch Metasploit console
msfconsole

Inside msfconsole, run:

db_status
version

Installing Metasploit on Windows

Installing Metasploit on Windows requires additional considerations due to antivirus software and permissions.

Step 1: Check Windows Security Alerts

If Windows Security blocks a verified installer component, review the alert before making a narrowly scoped exception for an authorized lab:

  1. Open Windows Security → Virus & threat protection
  2. Under "Virus & threat protection settings," click Manage settings
  3. Scroll to Exclusions and click Add or remove exclusions
  4. If approved for your authorized lab, limit any exclusion to the affected component and remove it when it is no longer needed

Step 2: Download the Windows Installer

  1. Visit: https://windows.metasploit.com/metasploitframework-latest.msi
  2. Download the .msi installer package
  3. Right-click the installer and select "Run as Administrator"

Step 3: Complete the Installation Wizard

  • Accept the license agreement
  • Choose installation directory (default: C:\metasploit-framework)
  • Select components (install all recommended components)
  • Wait for installation to complete (5-10 minutes)

Step 4: Initialize the Database

Open Command Prompt as Administrator and run:

# Navigate to Metasploit directory
cd C:\metasploit-framework\bin

# Initialize database
msfdb.bat init

# Launch Metasploit console
msfconsole.bat

Note: On Windows, Metasploit uses a bundled PostgreSQL instance, so you don't need to install it separately.

Installing Metasploit on macOS

macOS installation is straightforward using the official installer package.

Step 1: Download the macOS Installer

Visit: https://osx.metasploit.com/metasploitframework-latest.pkg

Step 2: Install the Package

  1. Double-click the downloaded .pkg file
  2. Follow the installation wizard
  3. Provide administrator password when prompted
  4. Allow installation to complete

Step 3: Install PostgreSQL (via Homebrew)

# Install Homebrew (if not already installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install PostgreSQL
brew install postgresql

# Start PostgreSQL service
brew services start postgresql

# Initialize Metasploit database
msfdb init

Step 4: Add Metasploit to PATH

# Add to your shell profile (~/.zshrc or ~/.bash_profile)
echo 'export PATH=/opt/metasploit-framework/bin:$PATH' >> ~/.zshrc

# Reload shell configuration
source ~/.zshrc

# Test Metasploit
msfconsole --version

Installing from Source (Advanced)

For developers or users who want the latest bleeding-edge features:

# Install dependencies (Debian/Ubuntu)
sudo apt install build-essential zlib1g-dev libpq-dev libpcap-dev libsqlite3-dev ruby-dev

# Clone the repository
git clone https://github.com/rapid7/metasploit-framework.git
cd metasploit-framework

# Install Ruby dependencies
gem install bundler
bundle install

# Run Metasploit
./msfconsole

Pros:

  • Access to latest features and fixes
  • Ability to contribute to development
  • Full control over installation

Cons:

  • Requires manual updates (git pull)
  • More complex troubleshooting
  • May encounter unstable builds

Database Configuration and Optimization

Why Use a Database?

While Metasploit can run without a database, many essential features require it:

  • Workspace management: Organize different penetration tests
  • Host tracking: Store discovered hosts and services
  • Credential storage: Save captured credentials
  • Loot management: Store files extracted from targets
  • Session tracking: Manage multiple active sessions

Essential Database Commands

Run these inside msfconsole:

# Check database status
db_status

# Create a new workspace
workspace -a pentest_project

# List all workspaces
workspace

# Switch between workspaces
workspace pentest_project

# View stored hosts
hosts

# View stored services
services

# View captured credentials
creds

Database Maintenance

# Reinitialization may remove stored data; back up and diagnose first.
# Use msfdb reinit only when rebuilding the database is intentional.

# Delete database
msfdb delete

# Check database service status
msfdb status

# Start database service
msfdb start

# Stop database service
msfdb stop

Common Installation Issues and Solutions

Issue 1: "Bundler gem required" Error

Symptoms: Error message stating "Metasploit requires the Bundler gem to be installed"

Solution:

# Install Bundler gem
gem install bundler

# Navigate to Metasploit directory
cd /opt/metasploit-framework

# Install dependencies
bundle install

Issue 2: Database Connection Failed

Symptoms: db_status shows "No database connection"

Solution:

# Ensure PostgreSQL is running
sudo systemctl status postgresql

# If not running, start it
sudo systemctl start postgresql

# On a new setup, initialize the database if it has not been created
sudo msfdb init

# Verify connection
msfconsole -q

Inside msfconsole, run db_status to verify the connection.

db_status

Issue 3: Permission Denied Errors (Linux/macOS)

Symptoms: Permission errors when running msfconsole or updating

Solution: Check which account owns the affected file or directory and repair only that specific permission using your package manager's guidance. Do not recursively change ownership of the installation or reinitialize the database as a routine permission fix.

Issue 4: Antivirus Blocking Installation (Windows)

Symptoms: Installation fails or files are quarantined

Solution:

  1. Review the quarantine event and verify the installer source
  2. If appropriate for an authorized lab, add a narrowly scoped exception
  3. Re-run the installer as Administrator

Issue 5: Ruby Version Conflicts

Symptoms: Errors about Ruby version compatibility

Solution:

# Check Ruby version
ruby --version

# Use the bundled Ruby (recommended)
# The installer includes the correct Ruby version

# If using system Ruby, install rbenv or rvm
# to manage Ruby versions separately

Updating Metasploit

Keeping Metasploit up-to-date ensures you have the latest exploits and security patches.

Updating on Linux (APT Installation)

# Update package lists
sudo apt update

# Upgrade Metasploit
sudo apt upgrade metasploit-framework

Updating via the Installer Method

Use the update mechanism documented for the installed package; check the current Rapid7 instructions for your platform.

Updating from Source

# Navigate to Metasploit directory
cd metasploit-framework

# Pull latest changes
git pull

# Update Ruby dependencies
bundle install

Verifying Your Installation

After installation, verify everything works correctly:

msfconsole

Inside msfconsole, run:

version
db_status
search ms17-010
use exploit/multi/handler
show options
exit

If all these commands work without errors, your installation is successful!

Post-install verification checklist

Tick each item before you consider the install done and start any authorized engagement:

  • msfconsole launches without Ruby or gem errors
  • version prints a current build number (framework updates almost daily)
  • db_status reports Connected to msf. Connection type: postgresql
  • PostgreSQL is enabled to start on boot (systemctl enable postgresql on Linux)
  • search ms17-010 returns module results (module database loaded)
  • use exploit/multi/handler then show options runs cleanly
  • A workspace exists for your project (workspace -a project_name)
  • (Windows) Any antivirus alert has been reviewed and any exception is limited to the authorized lab
  • You have written authorization for every target you plan to test

Once the console is running, you can build your first module commands visually instead of memorizing syntax:

Metasploit Command Builder

Visual Metasploit command generator with module presets, payload selector, and console command reference

Open the full Metasploit Command Builder tool →
Loading interactive tool...

Best Practices for Metasploit Installation

  1. Use Official Sources: Always download from official Rapid7 or Kali repositories
  2. Database Setup: Configure PostgreSQL immediately after installation
  3. Regular Updates: Update Metasploit weekly to get new modules and fixes
  4. Workspace Organization: Create separate workspaces for different projects
  5. Antivirus Exclusions: Properly configure exclusions to prevent false positives
  6. Backup Database: Regularly export database contents for important projects
  7. Resource Scripts: Create .rc files to automate common setup tasks
  8. Documentation: Keep notes on custom configurations and installed gems

Next Steps After Installation

Once Metasploit is installed, explore these essential topics:

  1. Learn msfconsole Commands: Familiarize yourself with search, use, set, and exploit commands
  2. Understand Modules: Explore the difference between exploits, auxiliary, and post modules
  3. Practice with Vulnerable VMs: Use Metasploitable, DVWA, or HackTheBox for legal practice
  4. Master Meterpreter: Learn advanced post-exploitation with Meterpreter sessions
  5. Database Workflow: Practice workspace management and data organization
  6. Automation: Create resource scripts for repetitive tasks

Helpful Resources:

Conclusion

Installing Metasploit Framework is straightforward once you understand the platform-specific requirements and potential pitfalls. Whether you choose Kali Linux for its pre-configured environment, Windows for familiarity, or macOS for convenience, following this guide ensures a smooth installation process.

Remember that Metasploit is a powerful tool that should only be used for authorized security testing. Always obtain explicit written permission before testing any system or network you don't own. Improper use may be illegal and result in serious legal consequences.

With Metasploit properly installed and configured, you're ready to begin your journey into penetration testing, vulnerability assessment, and ethical hacking. Start with vulnerable practice environments, continue learning through official documentation, and always practice responsible disclosure when you discover real vulnerabilities.

Ready to start building Metasploit commands? Try our Metasploit Command Builder to generate msfconsole commands with a visual interface, complete with module presets and payload selectors.

Don't wait for a breach to act

Get a free security assessment. Our experts will identify your vulnerabilities and create a protection plan tailored to your business.