Installing and Deploying QATrack+ on Windows Server

Note

This guide assumes you have at least a basic level of familiarity with Windows Server, SQL Server Management Studio, and the command line.

There are many community members who have successfully installed QATrack+ on Windows Server and can provide guidance and support. You can reach out to the QATrack+ community through the QATrack+ Google Group for assistance.

New Installation

This guide is going to walk you through installing QATrack+ on a Windows Server 2022 server with IIS serving static assets (images, javascript and stylesheets) and acting as a reverse proxy for a CherryPy web server which serves our Django application (QATrack+). The instructions have been tested with SQL Server 2022 database (and SQL Express).

If you are upgrading an existing QATrack+ installation from version 3.1, please see:

Note

This guide assumes you have SQL Server Management Studio (SSMS) and Internet Information Services (IIS) installed/enabled

The steps we will be undertaking are:

Prerequisites

Before we can begin installing the core site we need to ensure ensure the following software is installed on your server:

For convenience, these installers may be kept in a folder on the server (e.g. C:\deploy\installers) for future reference and re-use. Most of these installers can be run through traditional double-clicking, the Visual C++ Redistributable and ODBC Driver installers require Administrator privileges to run.

  • SQL Server Express: May be used if you do not have access to a full SQL Server instance SQL Server may be installed locally. This option should only be used if local IT resources will not support using a full SQL Server instance. QATrack+ should fit within the licensing limits of SQL Server Express, but it is up to each site to confirm their Microsoft licensing requirements.

Managing python dependencies and virtual environments can be a bit tricky on Windows. We have transitioned to using the uv package manager to handle this for us. To install QATrack+ run the following command in a PowerShell terminal with Administrator privileges:

>>  powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
>>  uv --version # this should print the version of uv installed, e.g. 0.11.20
# Close this PowerShell window we won't need it anymore, and open a new PowerShell window (without Administrator privileges) to continue with the installation.

Setting up the QATrack+ Application

Open a Windows PowerShell terminal and then create a directory for QATrack+ and check out the source code, use the following commands:

>>  mkdir C:\deploy
>>  cd C:\deploy
>>  git clone https://github.com/qatrackplus/qatrackplus.git

We’re now ready to install all the libraries QATrack+ depends on.

>>  cd qatrackplus
>>  git fetch origin
>>  git checkout releases/4.0
>>  uv venv --python 3.12
>>  uv sync --exact --extra win --extra mssql

Next, activate your new virtual environment:

>>  .\.venv\Scripts\Activate.ps1

Your command prompt should now be prefixed with (qatrackplus) or (.venv).

Can’t install uv? Use pip instead

A small number of sites can’t install uv – for example, due to a restricted PowerShell execution policy that blocks the installer script above, or no outbound internet access to astral.sh. If that’s you, QATrack+ and its Windows/SQL Server dependencies can be installed with plain pip, which reads the project and its extras straight from pyproject.toml:

>>  python -m venv .venv
>>  .\.venv\Scripts\Activate.ps1
>>  pip install ".[win,mssql]"

Two differences from the uv instructions above are worth knowing before you start:

  • You need Python 3.12 installed yourself, and on your PATH. The uv path does not – uv venv --python 3.12 downloads and manages an interpreter for you – so this is an extra prerequisite rather than a substitution. Check it with python --version before creating the virtual environment.

  • If you use Active Directory, the python_ldap wheel step in Authentication Backends is written as uv pip install. Use plain pip install C:\path\to\python_ldap-...whl instead, with the virtual environment activated.

This is a minimally-supported fallback path. It resolves dependency versions at install time rather than from uv.lock, so two sites installing a week apart can end up with different versions of the same dependency, and uv remains the recommended and tested method for everyone else. If you can use uv, use it.

Side note: `C:\deploy`

This folder is a convenient convention for storing the QATrack+ source code, virtual environment, and any other files related to your QATrack+ installation. You can use a different folder if you prefer, but you will need to adjust the instructions accordingly.

Creating a database with SQL Server

If you, or your IT department has familiarity with SQL Server, here is a quick summary of the configuration needed.

  • a SQL Server instance (either local or remote) with SQL Server Authentication enabled.

  • a database named qatrack.

  • a database user named qatrack with db_ddladmin, db_datawriter, db_datareader and db_owner permissions on the qatrack database.

  • a database user named qatrack_reports with db_datareader permissions on the qatrack database.

For most of us, the easiest way to set this up is to use SQL Server Management Studio (SSMS) and follow the instructions below. If you have a different method of setting up your database that meets the above requirements, that will work too.

Ensure SQL Server Authentication is enabled

Open SQL Server Management Studio and connect to ‘localhost’ or another database server.

In the Object Explorer frame right click on the server you are connected to and click Properties. In the dialog that opens click on Security, ensure SQL Server and Windows Authentication mode is selected and then click OK. Now right click on your server again and click Restart.

Create a new database

In the Object Explorer frame, right click the Databases folder and select “New Database…”.

Enter ‘qatrackplus’ as the database name and click OK.

Back in the Object Explorer frame, right click on the main Server Security folder and click New Login… Set the login name to ‘qatrack’, select SQL Server Authentication. Enter ‘qatrackpass’ (or whatever you like) for the password fields and uncheck Enforce Password Policy. Click OK.

New SQL User

Again in the Object Explorer frame, right click on the main Security folder and click New Login… Set the login name to ‘qatrack_reports’, select SQL Server Authentication. Enter ‘qatrackpass’ (or whatever you like) for the password fields and uncheck Enforce Password Policy. Click OK.

Now we have a database and two users, but the users don’t have permissions to do anything with the database yet. Back in the Object Explorer frame expand the qatrackplus database, right click on Security and select New->User.

New SQL User for Database

Enter ‘qatrack’ as both the User name and Login name and then in the Database Role Membership region select ‘db_ddladmin’, ‘db_datawriter’, ‘db_datareader’ and ‘db_owner’. Click OK.

../_images/db_user_2.png ../_images/db_user_3.png

The second user is readonly since it will only be used for queries and reports. In the new user dialog,enter ‘qatrack_reports’ as the User name and Login name and then in the Database Role Membership region select ‘db_datareader’. Click OK.

Configuring QATrack+ to use your new database

Copy the example local_settings file:

>>  cp deploy\win\local_settings.py qatrack\local_settings.py

and then edit it so that the NAME, USER, and PASSWORD settings match the way you set up your database above. Also, ensure you configure CSRF_TRUSTED_ORIGINS which is required. You can find your Device Name by pressing Windows Key + I -> System -> About. Alternatively, you can use hostname in a command prompt to get your device name, and ipconfig to get your IP address.

Your local_settings.py file should look something like the following (but with the correct values for your server):

DEBUG = False

DATABASES = {
    'default': {
        'ENGINE': 'mssql',
        'NAME': 'qatrackplus',
        'USER': 'qatrack',  # USER/PWD can usually be left blank if SQL server is running on the same server as QATrack+
        'PASSWORD': 'qatrackpass',
        'HOST': '', # leave blank unless using remote server or SQLExpress (use 127.0.0.1\\SQLExpress or COMPUTERNAME\\SQLExpress)
        'PORT': '', # Set to empty string for default. Not used with sqlite3.
        'OPTIONS': {
            'driver': 'ODBC Driver 17 for SQL Server'
        },
    },
    'readonly': {
        'ENGINE': 'mssql',
        'NAME': 'qatrackplus',
        'USER': 'qatrack_reports',
        'PASSWORD': 'qatrackpass',
        'HOST': '',
        'PORT': '',
        'OPTIONS': {
            'driver': 'ODBC Driver 17 for SQL Server'
        },
    }
}

ALLOWED_HOSTS = [
    '127.0.0.1',
    'localhost',
    'YOUR_DEVICE_NAME',
    'YOUR_IP_ADDRESS']

CSRF_TRUSTED_ORIGINS = [
    'http://localhost',
    'https://localhost',
    'http://127.0.0.1',
    'https://127.0.0.1',
    'http://YOUR_DEVICE_NAME',
    'https://YOUR_DEVICE_NAME']

Confirm you can connect to your database by running the showmigrations command:

>>  python manage.py showmigrations accounts

which should show output like:

accounts
    [ ] 0001_initial
    [ ] 0002_activedirectorygroupmap_defaultgroup
    [ ] 0003_auto_20210207_1027
    [ ] 0004_Auto_BigAuto_TimeZone_Django42
    [ ] 0005_v4_0_final

We will now create the database tables and load some configuration data into our new database from the command prompt. Createsuperuser will prompt you to create the highest level admin user for logging into QATrack+. Make sure to remember the username and password you create here as you will need it to log in to QATrack+ for the first time!

Now run the following commands to set up your database and load the default configuration data:

>>  python manage.py migrate
>>  python manage.py createsuperuser
>>  python manage.py collectstatic
>>  Get-ChildItem .\fixtures\defaults\*\*json | foreach {python manage.py loaddata $_.FullName}

If you want to enable internationalization, then you need to compile the messages catalogs for the languages you need.

Note

compilemessages runs GNU gettext’s msgfmt, which Windows does not include and Python does not provide. Without it the command stops with CommandError: Can't find msgfmt. Make sure you have GNU gettext tools 0.15 or newer installed., no catalogue is compiled, and QATrack+ then serves every string in English with nothing else to say that anything failed.

Install the GNU gettext binaries for Windows and make sure the folder holding msgfmt.exe is on PATH for the session you run compilemessages in. If you only need English, you can skip this step and the command altogether.

>>  python manage.py compilemessages -l fr
>>  python manage.py compilemessages -l fr_CA
>>  python manage.py compilemessages -l es

We now have a database, we have configured QATrack+ to use it, and we’ve loaded the default configuration data. Next, we should test that everything is working correctly by running the development server with python manage.py runserver and navigating to http://localhost:8000/ in a browser on the server. You should see a poor approximation of the QATrack+ login page (it won’t look like this once we’re finished!). If you see any errors, check the terminal output for details on what went wrong. If you can log in successfully, then we know our database is configured correctly and we can move on to the next step.

Configuring CherryPy to Serve QATrack+

Next we need to set up a web server to serve QATrack+ and allow users to log in and use it. In order to have QATack+ start when you reboot your server, or restart after a crash, we will run QATrack+ with a CherryPy server installed as a Windows service (running on port 8080, see note below if you need to change the port).

Open a new PowerShell window with Administrator privileges (right click on PowerShell and click “Run as Administrator”) and run the following commands:

>>  cd C:\deploy\qatrackplus
>>  .\deploy\win\install_winsw.ps1

Open the Windows Services dialog and confirm the QATrack+ Web Service is installed and has a status of Running.

CherryPy Service

Next open a browser on the server and navigate to http://localhost:8080/ and ensure you see a plain login form there (it won’t look like this once we’re finished!). If not, check the logscherry_py_err.log file for any errors.

Your QATrack+ installation is now installed as a Windows Service running on port 8080 (see note below). You may also wish to configure the service to email you in the event of a crash (see the Recovery tab of the QATrack+ Web Service configuration dialogue).

Note

If you need to run QATrack+ on a different port, edit C:\\deploy\\qatrackplus\\run_cherrypy.py set the server.socket_port variable to a different port (e.g. 8008), and run .\qatrack-service.exe restart to update the service. You will also need to update the URL rewrite rules in IIS to point to the new port.

Setting up IIS

To start open up the Internet Information Services (IIS) application. We are going to use IIS for two purposes: first, it is going to serve all of our static media (css, js and images) and second it is going to act as a reverse proxy to forward the QATrack+ specific requests to CherryPy.

If IIS is not installed, open Server Manager, select Manage -> Add Roles and Features, click Next until you reach Server Roles, check Web Server (IIS), and follow the prompts to install it. The default options are sufficient.

Before configuring IIS, please make sure you have both URL Rewrite 2.1 and Application Request Routing 3.0 IIS modules installed. These can be installed manually from the provided links.

After installing these modules, you will need to close & re-open IIS. Alternatively, the deploy\win\iis_install.ps1 script can automate some of this setup. When testing static access, ensure the IIS server is running.

Enabling Proxy in Application Request Routing

Application Request Routing needs to have the proxy setting enabled. To do this, click on the top level server in the left side panel, and then double click the Application Request Routing icon. In the Actions panel click the Server Proxy Settings and then check Enable proxy at the top. Leave all the other settings the same and click Apply and then Back to ARR Cache.

Enabling Static Content Serving in IIS

IIS is not always set up to serve static content. To enable this, open the Server Manager software, click Manage, then Add Roles and Features then Next, Next. In the Roles widget, select Web Server(IIS)->Web Server->Common HTTP Features and make sure Static Content is selected. If it isn’t, enable that role.

Setting up the site and URL rewrite rules

Once you have Application Request Routing installed and proxies enabled, in the left panel of IIS under Sites, select the default Web Site and click Stop on the right hand side.

Warning

Stopping it is not enough: it starts itself again at the next reboot. The default site and QATrack+’s site are both bound to port 80, so whichever is running owns it, and Stop does not change the setting IIS reads when Windows boots. Measured on a fresh install, 2026-10-29: after one restart the default site was running, QATrack+’s was stopped, and the address answered with Windows’ own “IIS Windows Server” page.

With the site still selected, click Advanced Settings in the right-hand panel and set Start Automatically to False. Then it stays stopped. (deploy\win\iis_install.ps1 does this for you if you used the script.)

Stop default website

Stop default website

Now right click on Sites and click Add Web Site

Add a new web site

Add a new web site

Enter QATrack Static for the Site Name and “C:\deploy\qatrackplus\qatrack\” for the Physical Path then click OK and answer Yes to the warning.

To test that setup worked correctly open a browser on your server and enter the address http://localhost/static/qa/img/tux.png You should see a picture of the Linux penguin.

Next, select the top level server in the Connections pane and then double click URL Rewrite:

URL Rewrite

URL Rewrite

In the top right click Add Rule and select Blank Rule.

Give it a name of QATrack Static and enter ^(static|media)/.* for the Pattern field, and select None for the Action type. Make sure Stop processing of subsequent rules is checked.

Static Rule

Static URL Rewrite Rule

When finished click Apply, then Back To Rules and then add another blank rule. Give it a name of QATrack Reverse Proxy, enter ^(.*) for the Pattern and http://localhost:8080/{R:1} for the Rewrite URL. In the Server Variables section add a new Server Variable with the Name=HTTP_X_FORWARDED_HOST and the Value=yourservername.com (replace yourservername with whatever your domain is!). Finally, make sure both Append query string and Stop processing of subsequent rules are checked.

URL Rewrite Reverse Proxy

URL Rewrite Reverse Proxy

Your URL rewrites should look like the following (order is important!)

URL Rewrite rules

URL Rewrite rules

You should now be able to visit http://localhost/ in a browser on your server and see the QATrack+ login page. Congratulations, you now have a functional QATrack+ setup on your Windows Server!

If you see a “403.14 Forbidden” error, double check you added the URL rewrite rules to the top level server, and not the QATrack Static site.

If you see a “403 CSRF” error, double check that you set the CSRF_TRUSTED_ORIGINS setting in your local_settings.py file to include your server name, url, and IP address.

If you see a “502.3 Bad Gateway” error, double check that your QATrack+ Web service was installed correctly and is running.

Note

There are many different ways to configure IIS. The method I’ve used above is simple and works well when QATrack+ is the only web service running on a server.

Setting up Django Q

As of version 3.1.0, some features in QATrack+ rely on a separate long running process which looks after periodic and background tasks like sending out scheduled notices and reports. We are going to use Windows Task Scheduler to run the Django Q task processing cluster.

Open the Windows Task Scheduler application and click Create Task. Give the task a name of “QATrack+ Django Q Cluster”. Click the Change User or Group… button and in the Enter the object name to select box put SYSTEM, then click Check Names and OK.

QCluster Task

QCluster Task

On the Triggers tab, click New… and in the Begin the task: dropdown select At startup. Under Advanced settings, tick Delay task for: and choose 5 minutes, then click OK.

Warning

Do not skip the delay when SQL Server runs on the same machine. SQL Server Express installs as Automatic (Delayed Start), so it is still starting for a minute or two after Windows has booted - and a Django Q cluster that starts first never connects. The task stays Running and the process stays alive, so nothing looks wrong, while manage.py qinfo reports 0 clusters and 0 workers and scheduled notices and reports stop silently until somebody restarts the task by hand.

Measured twice on Windows Server: 2026-10-18, and again on 2026-10-29 on a fresh 4.0.2 install, where the cluster’s process started at boot, SQL Server reached Running two minutes later, and qinfo still read 0/0 ninety seconds after that. Restarting the task gave 1 cluster and 2 workers within thirty seconds.

The web service does not need this: Django connects per request, so CherryPy recovers on its own once the database answers.

QCluster Trigger

QCluster Trigger

Now go to the Actions tab and click New…. In the Program/script: box enter C:\deploy\qatrackplus\.venv\Scripts\python.exe. In the Add arguments (optional): field enter manage.py qcluster, and in the Start in (optional): field put C:\deploy\qatrackplus (no trailing slash!).

Warning

On the Settings tab, untick Stop the task if it runs longer than:. Task Scheduler sets that to three days by default, so a cluster left alone stops after three days and nothing restarts it - the same silent failure as the one above, on a slower clock.

QCluster Action

QCluster Action

Click OK, then right click on the task and select Run. Go back to your PowerShell window (or open a new one) and confirm your task cluster is running with python manage.py qmonitor which should show something like:

 Host            Id      State    Pool    TQ       RQ       RC    Up

YOUR-SERVER    e0474f3f  Idle     2       0        0        0     0:05:53

     ORM default     Queued    0    Success   48   Failures       0

                     [Press q to quit]

If the line between Host and ORM default is blank then there is a problem with the Windows Task you created.

Tell QATrack+ its own name and address

Do this once, after the first start. Until you do, QATrack+ calls itself example.com:

  • every browser tab reads example.com: Log In, and so does the name in the page header;

  • the links in emailed notifications and scheduled reports point at http://example.com/..., so nobody who receives one can click through to your server.

Nothing is broken and no data is at risk - QATrack+ simply has not been told what it is called.

Where the value lives

It is a row in the database, not a line in a settings file. Django keeps a small table of one row holding two fields, and QATrack+ reads both from there:

  • Domain name - the host name people type to reach QATrack+, for example qatrack.myclinic.ca. The emailed links are built from this.

  • Display name - the words shown in the browser tab and the page header, for example QATrack+ or Medical Physics QC.

The row ships as example.com for both, because that is Django’s default and the software cannot know your host name.

Warning

There is a SITE_NAME setting, and on a native install changing it does nothing. It exists in qatrack/settings.py, and on Docker it can be set in .env - but QATrack+ reads the name from the database row, so the setting is ignored. Only the row matters. If you have already set SITE_NAME and seen no change, this is why.

Note

Two different things in the admin are called “Sites”. They are unrelated:

  • Sites on its own, with exactly one row and the fields Domain name and Display name - this is the one on this page.

  • Sites under Units, where you group treatment units by physical location. That is a QATrack+ feature for your own clinic layout and has nothing to do with the name of the website.

Setting it

In the admin, open Sites, click the single example.com row, and set both fields. Or from a terminal:

python manage.py shell -c "
from django.contrib.sites.models import Site
s = Site.objects.get_current()
s.domain = 'qatrack.myclinic.ca'; s.name = 'QATrack+'; s.save()"

On Docker, run that inside the container:

docker compose exec django python manage.py shell -c "
from django.contrib.sites.models import Site
s = Site.objects.get_current()
s.domain = 'qatrack.myclinic.ca'; s.name = 'QATrack+'; s.save()"

Then restart the application

Changing the row is not enough on its own. Django reads it once per process and keeps it, so a running server goes on serving the old value and the change looks as though it did nothing:

Installation

Restart

Ubuntu Linux

sudo supervisorctl restart gunicorn django-q2

Windows Server

restart the QATrack+ Web Service in the Windows Services dialog

Docker

docker compose restart django django-q

Reload the login page afterwards; the tab should now read your display name.

Note

If you ever rebuild the database from the default fixtures, the row goes back to example.com. Re-apply it after any rebuild. Upgrading does not touch it.

Restart the server, and check it came back

Do this before you hand the site over. Everything on this page has been set up to survive a restart - a Windows service, a scheduled task, an IIS site - and until the server has restarted once, none of that is tested. Two of the three have failed this check on a correctly installed site, so it is worth ten minutes now rather than at the first Windows Update.

Restart Windows, wait for it to settle - give SQL Server a few minutes, since it starts late - and then check all three:

>>  Get-Service "QATrack+ Web Service" | Select-Object Status, StartType
>>  Get-Website | Select-Object Name, State, @{n='AutoStart';e={ (Get-ItemProperty "IIS:\Sites\$($_.Name)" -Name serverAutoStart).Value }}
>>  cd C:\deploy\qatrackplus
>>  .\.venv\Scripts\python.exe manage.py qinfo

What you are looking for:

  • the web service Running, with start type Automatic;

  • QATrack Static started, and Default Web Site both Stopped and AutoStart False - if the default site is running, it has taken port 80 and QATrack+ is unreachable;

  • qinfo reporting 1 cluster with workers. If it reports 0 clusters while the task shows as running, the cluster started before SQL Server did: restart the task and add the startup delay described in Setting up Django Q.

Then open the site in a browser and sign in. A service that is running is not the same thing as a site that answers.

What Next

  • Check the the settings page for any available customizations you want to add to your QATrack+ installation (don’t forget to restart both your QATrack+ Web Service, and Django Q cluster via the task scheduler after changing any settings!)

  • Set up a Backup Strategy. You must routinely backup your database, the media folder, and your local_settings.py file. Please consult with your IT department to automate this. More details can be found here: backup of your QATrack+ installation.

  • Read the Administration Guide, User Guide, and Tutorials.

Wrap Up

This guide shows only one of many possible method of deploying QATrack+ on Windows. It is very similar to what is used at The Ottawa Hospital Cancer Centre and it has proven to be a very solid setup. If you’re stuck with a Windows stack it will likely work for you too. Please post on the QATrack+ Google Group if you get stuck!