---
title: "Installation: Running as a Service"
description: "Register RavenDB as an OS service on Windows or Linux to ensure automatic startup on machine boot and reduce server downtime."
url: "https://docs.ravendb.net/7.2/start/installation/running-as-service"
version: "7.2"
---

# Installation: Running as a Service

> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

## Installation: Running as a Service

- Running servers as OS services reduces downtime whenever a machine restarts because the servers automatically start every time the machine boots.

- After completing the Server configuration process either via the [Setup Wizard](https://docs.ravendb.net/7.2/start/installation/setup-wizard/overview.md)
  or [Manually](https://docs.ravendb.net/7.2/start/installation/manual.md), you can register the Server as a Service using the `rvn` tool that can be found inside the RavenDB Server
  distribution package.

- After registering RavenDB as a service, be sure to check your OS "Services" manager to see that the "RavenDB" service is there
  and that the Startup Type is "Automatic".

In this page:

- [Windows](#windows)
  - [Registering](#registering)
  - [Unregistering](#unregistering)
  - [Starting and Stopping](#starting-and-stopping)
- [Linux - Ubuntu](#linux---ubuntu)

> **Info:** Prerequisites {#prerequisites}
>
> The prerequisites for running RavenDB as a Service are defined [here](https://docs.ravendb.net/7.2/start/getting-started.md#prerequisites).

## Windows

### Registering

To register RavenDB as a Service on Windows OS, run PowerShell with administrator privileges.  
Navigate to the RavenDB package root and execute:

```powershell
.\setup-as-service.ps1
```

If you receive the following error:  
"setup-as-service.ps1 cannot be loaded. The file \[YourFileLocation] is not digitally signed"

1. Run the following command `Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass`.
2. Affirm the "Execution Policy Change" with `Y`.
3. Run `.\setup-as-service.ps1` again.

Alternatively, navigate to the node **Server** folder and execute the following command:

```powershell
.\rvn.exe windows-service register --service-name RavenDB
```

If you want to run the service under a non-default user (**Local Service** is default) then execute the following command:

```powershell
.\rvn.exe windows-service register --service-name RavenDB --service-user-name MyUser --service-user-password MyPassword
```

### Unregistering

You can end the service using:

```powershell
.\uninstall-service.ps1
```

Alternatively, use the 'unregister' command as follows:

```powershell
.\rvn.exe windows-service unregister --service-name RavenDB
```

### Starting and Stopping

Service can be also controlled using the `start` and `stop` commands:

```powershell
.\rvn.exe windows-service stop --service-name RavenDB
.\rvn.exe windows-service start --service-name RavenDB
```

## Linux - Ubuntu

You can run RavenDB as a daemon by running the script `install-daemon.sh` from the package root.

Alternatively, open a bash terminal, and create the following file `/etc/systemd/system/ravendb.service`, using super-user permissions:

```bash
[Unit]
Description=RavenDB NoSQL Database
After=network.target

[Service]
LimitCORE=infinity
LimitNOFILE=65535
LimitRSS=infinity
LimitAS=infinity
LimitMEMLOCK=infinity
TasksMax=infinity
StartLimitBurst=0
Restart=on-failure
Type=simple
TimeoutStopSec=300
User=<desired-user>
ExecStart=<path-to-RavenDB>/run.sh

[Install]
WantedBy=multi-user.target
```

Note: Replace `<desired-user>` with your **username** and `<path-to-RavenDB>` with your **path**.

Then register the service and enable it on startup:

```bash
systemctl daemon-reload
systemctl enable ravendb.service
```

Start the service:

```bash
systemctl start ravendb.service
```

View its status using:

```bash
systemctl status ravendb.service
```

or

```bash
journalctl -f -u ravendb.service
```
