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:

ServicePurpose
Metasploit Pro ServiceRuns tasks and handles licensing
Metasploit Thin ServiceRuns the web interface
Metasploit WorkerRuns asynchronous tasks, including reports and backups
Metasploit PostgreSQLDatabase 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.

  1. Choose Start > Programs > Metasploit > Stop Services. If the system prompts you to allow the program to make changes to the computer, click Yes.
  2. 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:

1
msadmin@ubuntu:~$ systemctl list-units 'metasploit*'
2
UNIT LOAD ACTIVE SUB DESCRIPTION
3
metasploit-config-swapper.service loaded active exited Metasploit Pro restore management service
4
metasploit-env.service loaded active exited Metasploit Pro environment generator
5
metasploit-postgresql-env.service loaded active exited Metasploit Pro PostgreSQL environment generator
6
metasploit-postgresql.service loaded active running PostgreSQL database server
7
metasploit-prosvc.service loaded active running Metasploit Pro engine service
8
metasploit-ui.service loaded active running Metasploit Pro web service
9
metasploit-worker.service loaded active running Metasploit Pro worker
10
metasploit.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:

ServicePurpose
metasploit-postgresql.serviceDatabase server
metasploit-prosvc.serviceRuns tasks and handles licensing
metasploit-ui.serviceRuns the web interface
metasploit-worker.serviceRuns 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:

ServicePurpose
postgresqlDatabase server
prosvcRuns tasks and handles licensing
metasploitRuns the web interface
workerRuns 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.

1
msadmin@ubuntu:~$ sudo '/opt/metasploit/ctlscript.sh'
2
usage: /opt/metasploit/ctlscript.sh help
3
/opt/metasploit/ctlscript.sh (start|stop|restart|status)
4
/opt/metasploit/ctlscript.sh (start|stop|restart|status) postgresql
5
/opt/metasploit/ctlscript.sh (start|stop|restart|status) prosvc
6
/opt/metasploit/ctlscript.sh (start|stop|restart|status) metasploit
7
/opt/metasploit/ctlscript.sh (start|stop|restart|status) worker
8
9
help - this screen
10
start - start the service(s)
11
stop - stop the service(s)
12
restart - restart or start the service(s)
13
status - 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.