Windows Server (advanced)¶
If you are just testing your app on your personal computer, you can use
otree zipserver or
otree devserver. You don’t need a full server setup as described below,
which is necessary for sharing your app with an audience.
This section is for people who are experienced with setting up web servers. If you would like an easier and quicker way, we recommend using Heroku.
Why do I need to install server software?¶
oTree’s development setup (using
zipserver with a SQLite database)
is not designed for running actual studies. One known risk is that
if you don’t install Postgres, your SQLite database
might lock when multiple users are accessing it simultaneously.
For a short, small study, you might be able to get away with just using
as long as you set up your IP address as described in Configure your computer to be a server (advanced)
However, for reliable results, you should follow the steps below.
oTree’s default database is SQLite, which is fine for local development, but insufficient for production, because it often locks when it multiple clients are accessing it.
We recommend you use PostgreSQL.
Install Postgres for Windows,
using the default options. Note down the password you chose for the root
Launch pgAdmin, and using the browser, create a new database called
Now, edit your
pg_hba.conf, which is usually located in
On the lines for
IPv6, change the
Now, set your
DATABASE_URL environment variable to this:
Then restart your Command Prompt so the environment variable gets loaded.
DATABASE_URL is defined, oTree will use it instead of the default SQLite.
To use Postgres, you need to install psycopg2 with
pip3 install psycopg2.
If the pip install doesn’t work,
download it here.
(If you are using a virtualenv, note the special installation instructions on that page.)
If all the above steps went well, you should be able to run
You should download and run Redis for Windows.
Redis should be running on port 6379. You can test with
which should output
Run the production server¶
otree runprodserver 80
See here for full instructions. The steps are essentially the same as on Linux.
Set environment variables¶
You should set