Metasploit service can't bind to port 3790

Issue

Metasploit won't bind to port 3790.

Why

If you have deleted the Metasploit directory and are trying to reinstall Metasploit Pro, you may encounter an error that Metasploit cannot bind to port 3790.

Fix

First you will need to kill the Metasploit Service, then reinstall Metasploit.

Kill the Metasploit Service on Linux

To kill the Metasploit service on Linux, you need to run the following command to find its PID:

1
sudo netstate -anpl | grep 3790

After you identify the PID, you can kill the service by running the following command:

1
sudo kill -9 <PID>

After the service daemon has been killed, you should run the following command to verify that all Metasploit directories have been removed:

1
sudo find / -name metasploit*

If there are any remaining Metasploit artifacts, you should delete them.

Killing the Metasploit Service on Windows

To kill the Metasploit service on Windows, you need to go to the Services list, which can be accessed from the Control Panel (Administrative Tools > Services) or from the Task Manager.

To do this from the Windows Terminal, you need to run the following command to find its PID:

1
sc queryex MetasploitProSVC

After you identify the PID, you can kill the service by running the following command:

1
taskkill /PID <PID>

You may need administrator level access to kill the PID.