Restarting Metasploit Services
There may be times when you need to restart the Metasploit services, such as after installation. Metasploit includes scripts that can be used to stop and restart all Metasploit related services.
Windows
On Windows you can stop, start or restart the following services:
Service | Purpose |
---|---|
Metasploit Pro Service | Runs tasks and handles licensing |
Metasploit Thin Service | Runs the web interface |
Metasploit Worker | Runs asynchronous tasks, including reports and backups |
Metasploit PostgreSQL | Database server |
There are two ways to manage running services. One way is to start and stop services from the Start Menu. The Start Menu does not allow you to control which services are being stopped, started or restarted. The Start Menu stops and starts all services.
- Choose Start > Programs > Metasploit > Stop Services. If the system prompts you to allow the program to make changes to the computer, click Yes.
- Choose Start > Programs > Metasploit > Start Services. Metasploit can take up to ten minutes to restart.
The second way is to manage them from the “Services” app. In the Start Menu, choose the Search Icon, then type “Services”. Open the Services app that displays in your search results.
Once in “Services” scroll down until you find Metasploit. You can stop, pause or restart each service individually from this view.
Restart Time
Wait a few minutes before accessing the web interface.
Linux
On Linux, Metasploit Pro supports installations using an init script for init.d-based distributions. Additionally, since the 4.19.1-2021032901 release, you can install Metasploit Pro as a systemd service on distributions that use systemd by checking the Install as system service box. Currently, the type of service that is installed is determined during the installation and cannot be changed afterwards except by reinstalling Metasploit Pro. Linux distributions that use systemd by default include Ubuntu since 15.04, RHEL and CentOS since 7.0, Debian since 8.0, Fedora since 15, and openSUSE since 12.02.
Under systemd, you can use systemctl
to start, stop, restart, or get the status of the following services:
1msadmin@ubuntu:~$ systemctl list-units 'metasploit*'2UNIT LOAD ACTIVE SUB DESCRIPTION3metasploit-config-swapper.service loaded active exited Metasploit Pro restore management service4metasploit-env.service loaded active exited Metasploit Pro environment generator5metasploit-postgresql-env.service loaded active exited Metasploit Pro PostgreSQL environment generator6metasploit-postgresql.service loaded active running PostgreSQL database server7metasploit-prosvc.service loaded active running Metasploit Pro engine service8metasploit-ui.service loaded active running Metasploit Pro web service9metasploit-worker.service loaded active running Metasploit Pro worker10metasploit.target loaded active active Metasploit Pro services
The most important of these is metasploit.target
, which controls the state of the Metasploit Pro installation as a whole. Metasploit Pro is configured to start automatically at boot, but you can disable it in the terminal with:
sudo systemctl disable metasploit.target
You can re-enable it with:
sudo systemctl enable metasploit.target
Finally, run the following command to restart all of Metasploit Pro's services:
sudo systemctl restart metasploit.target
The other major services are:
Service | Purpose |
---|---|
metasploit-postgresql.service | Database server |
metasploit-prosvc.service | Runs tasks and handles licensing |
metasploit-ui.service | Runs the web interface |
metasploit-worker.service | Runs asynchronous tasks, including reports and backups |
These services expose their logs with systemd, and you can view them with journalctl
. For example, to view the web interface's logs, run the following in a terminal:
journalctl -u metasploit-ui.service
These logs are also gathered as a part of our diagnostic log gathering process. The remaining services handle minor file generation tasks needed by the systemd integration.
Using the control scripts in the Linux install, you can start, stop, restart, or get the status of the following services:
Service | Purpose |
---|---|
postgresql | Database server |
prosvc | Runs tasks and handles licensing |
metasploit | Runs the web interface |
worker | Runs asynchronous tasks, including reports and backups |
In the terminal, type /opt/metasploit/ctlscript.sh
. You might need to use sudo
before running the script. This will bring up the following options.
1msadmin@ubuntu:~$ sudo '/opt/metasploit/ctlscript.sh'2usage: /opt/metasploit/ctlscript.sh help3/opt/metasploit/ctlscript.sh (start|stop|restart|status)4/opt/metasploit/ctlscript.sh (start|stop|restart|status) postgresql5/opt/metasploit/ctlscript.sh (start|stop|restart|status) prosvc6/opt/metasploit/ctlscript.sh (start|stop|restart|status) metasploit7/opt/metasploit/ctlscript.sh (start|stop|restart|status) worker89help - this screen10start - start the service(s)11stop - stop the service(s)12restart - restart or start the service(s)13status - show the status of the service(s)
To start Metasploit:
/opt/metasploit/ctlscript.sh start
To start a specific service:
/opt/metasploit/ctlscript.sh start worker
Restart Time
Wait a few minutes before accessing the web interface.