My Habitica Instance -

I subscribe to /r/selfhosted and they have a link to another fantasic page which lists tons of software you can host on your own system. From there I found Habitica which is:

Habitica is a free habit building and productivity app that treats your real life like a game. With in-game rewards and punishments to motivate you and a strong social network to inspire you, Habitica can help you achieve your goals to become healthy, hard-working, and happy.

I provisioned myself a new VPS with the following specs:

  • 80GB Disk Space
  • 4GBs RAM
  • 4-cores for CPU
  • Ubuntu 15.04

Now Habitica has some installation instructions which can be found here, but I found that I did some Googling around since I hit a couple snags while installing. So before we jump into getting Habitica installed there's some pre-requisites that need to be installed first.

I had some issues running npm install so I had to adjust my DCACHESIZE in the containers OpenVZ configuration. I used the following value(s):


Of note, once I made this change, I restarted the container and confirmed I could then run npm install without issue.


Habitica utilizes MongoDB for storing data. I utilize this guide here for getting it installed into my Ubuntu 15.04 environment. You should be able to utilize the following steps to get it installed if on Ubuntu 15.04 (assuming you're running the commands as root:

  1. Install the MongoDB repository key:
    apt-key adv --keyserver hkp:// --recv 7F0CEB10
  2. Now add the MongoDB repository to the system:
    echo "deb wheezy/mongodb-org/3.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
  3. Now run apt-get update
  4. Now install MongoDB!
    apt-get install mongodb-org
  5. You can now run the following to ensure MOngoDB is up and running:
    sudo systemctl status mongod

NodeJS & NPM

Next we'll want to get NodeJS and npm installed. This should be pretty easy.

apt-get install python-software-properties
apt-add-repository ppa:chris-lea/node.js
apt-get install nodejs
apt-get install npm
apt-get install nodejs-legacy

Git - Cloning HabitRPG/habitrpg

Now we want to get the Habitca code to run. First you'll want to create your own fork of the Habitica code. This can easily be done from the GitHub interface. You can find the Habitica repository here.

Once you have your own fork, you can run the following:

git clone
git remote add upstream

You can then run git remote -v and you should see output similar to this:

origin (fetch)
origin (push)
upstream (fetch)
upstream (push)

Of note, I put my Habitica code into /opt/ so it all lives in /opt/habitrpg.

Configuring and Running Habitica

We're almost there, just a few more steps. I found that you need to install the following package in Ubuntu to when running npm install.

apt-get install libkrb5-dev

Next run these commands to install some packages:

npm install -g gulp grunt-cli bower
bower install --allow-root
npm install

This should install everything that Habitica needs to run. Next you'll want to copy over the example configuration file:

cp config.json.example config.json

If you don't plan on using email then nothing needs to be done with the file. However if you plan on needing email to work you'll want to edit at least the ADMIN_EMAIL, SMTP_USER, SMTP_PASS and SMTP_SERVICE values.

Once that is done you should be ready to start up Habitica!

npm start

It may take a minute to start up, but when it does you should be able to visit http://localhost:3000.

Bonus Items - Nginx & Mailgun

Alright, so if you're like me and you've install Habitica on a remote VPS, obviously accessing http://localhost:3000 isn't going to work. This is were Nginx comes in and I use it as a proxy so I can access my Habitica instance at instead. First you'll want to install Nginx:

apt-get install nginx

Next, you'll want to create a Nginx configuration file for Habitica:

cd /etc/nginx/site-available
nano habitica

Now you'll want to put the following into your habitica file:

# Upstream configuration
upstream shout_upstream {  
     keepalive 64;

# Public
server {  
    listen 80;
    server_name; # domain of my site

   location / {
        proxy_http_version 1.1;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-NginX-Proxy    true;
        proxy_set_header   Host             $http_host;
        proxy_set_header   Upgrade          $http_upgrade;
        proxy_redirect     off;
        proxy_pass         http://shout_upstream;

Next, run this comamnd:

cd /etc/nginx/sites-enabled
ln -s /etc/nginx/sites-available/habitica .
/etc/init.d/nginx restart

Now you should be able to access your Habitica instance at your own domain!

If you'd like to use email with your Habitica instance you can set it up with a wide variety of services. I needed to use email to reset my password so I had to get it setup and running. You will need to open the config.json file in your favorite text editor and locate the following lines:

"SMTP_PORT": 587,
"SMTP_TLS": true,

I used Mailgun to handle email for my Habitica instance, but there's quite a wide variety of popular email services this can work with. I also tested Gmail and confirmed that works fine as well.

One of the really nice things about Habitica is that when you save this file, the server will reload itself automatically and use any new configurations.


I am still learning about how Habitica works, how the MongoDB schema is setup as well as about MongoDB commands as well. It's fun and I think Habitica will be a fun way to keep track of tasks I need to be doing. Anyone is welcome to sign up for an account on the server as well!