Guide to Setting Up Discourse Development Environment - Windows 11

Hi Everyone,

After spending some time attempting to get a working development environment up and running under Windows 11 / WSL2 I thought I would share the steps that I have followed.

This is my first post here so I hope that this is of use to somebody :slight_smile: I am a Systems Administrator used to working with Windows so this has been an interesting journey learning Linux / Ruby / Discourse etc.

A few things seem to have changed since the guide for Windows 10 was written and I ran into a few issues along the way (and from reading the comments, I wasn’t the only one!)

I can confirm that the following instructions worked on my Windows 11 Pro 22H2 install & also on my Windows Insider build of the upcoming Windows 11 23H2 Release Preview.

I’ll try to keep the instructions as short and straightforward as possible :slight_smile:

Initial Preparation

  1. Check for any WSL updates and install them if applicable. From a Windows Powershell window use this command:-

wsl.exe --update

  1. Install Ubuntu on WSL2 using this command:-

wsl.exe --install -d Ubuntu

  1. Follow the onscreen prompts to create the username and password

  2. Once you’re in the Ubuntu terminal, check for and install all applicable updates

sudo apt update && sudo apt upgrade -y

  1. Now that everything is updated we can proceed :slight_smile:

WSL Modifications

  1. Before cloning Discourse, run the following command to open the /etc/wsl.conf file:-

sudo nano /etc/wsl.conf

  1. At the bottom of the existing file, add the following , press Ctrl + X to save the changes and press “Y” when prompted.
enabled  = true
root     = /mnt/
options  = "metadata,umask=22,fmask=11"
  1. Completely close the WSL terminal and relaunch it for these changes to properly apply.

  2. Now copy and paste the following one-line installation script to set up the development environment. Depending on the speed of your computer and/or internet connection this might take a bit of time to complete, so go and grab a coffee or something!

bash <(wget -qO-

  1. Start the PostgreSQL service:-
sudo service postgresql start

  1. Because we’re running in WSL2 I got a warning message about the VM running out of memory, which can be solved by running the following
sudo sysctl vm.overcommit_memory=1

  1. Run the following so that the redis-server automatically restarts:-
redis-server --daemonize yes
  1. Clone Discourse into the home folder:-
git clone ~/discourse

  1. Change to the newly-created Discourse folder:-
cd ~/discourse

  1. Run the following commands (I did them one line at a time)(Unsure whether this is necessary or if they can be copied and pasted in one go)
source ~/.bashrc

bundle install

yarn install

  1. Setup the environment:-
RAILS_ENV=development bundle exec rake db:create db:migrate

  1. Start Discourse
DISCOURSE_HOSTNAME=localhost UNICORN_LISTENER=localhost:3000 bin/ember-cli -u

  1. Open a separate terminal , change into the Discourse directory using cd ~/discourse and run rails admin:create - follow the instructions to set up your Admin user account.

  2. Go to http://localhost:4200 in a web browser and Discourse should all be up and running :slight_smile:


This part might fail. If it does click start , type turn windows features on or off
Enable virtual machine platform

Resume the commands.


Thanks for adding this Andrew!

One very important thing that I struggled with for a while to figure out is that the repo absolutely must be on the WSL filesystem (i.e., NOT on /mnt/*). Otherwise, you’ll either get all kinds of odd errors or have a very, very, very slow instance.

This is supposed to be common knowledge, but from my interaction with other devs, it kind of isn’t.

Hi AliBenBongo :wave:

Thank you for this guide.

Out of curiosity, did you try Install Discourse on Windows 10 for development but faced issues on Windows 11?

I followed this official guide less than two months ago to set up my dev install on Win11, and it worked flawlessly.


That’s interesting yes I did try that guide first and ran into many error messages. I can’t remember specifically but some of the error messages were mentioned in the comments section of that same thread …

Think this is a good thing in the end as I’ve definitely got more knowledge now through resolving the issue myself and then writing this guide up! :slight_smile:

1 Like