Beginners Guide to Install Discourse on Windows 10 for Development

So you want to set up a development environment for Discourse on Windows 10? You can do it easily using Windows Subsystem for Linux feature. It is faster too :star_struck:.

This setup requires the WSL 2 installation. It is only available in Windows 10 builds 18917 or higher. We’ll assume that you already installed Windows Subsystem for Linux 2 (Ubuntu) on your Windows 10 system. Let’s begin!

  1. Initially follow the steps from the topic Beginners Guide to Install Discourse on Ubuntu for Development until the step Clone Discourse.

    Before setting up the database you have to start PostgreSQL service & Redis server manually using following commands

    sudo service postgresql start
    redis-server --daemonize yes
  2. Then go through all the remaining steps of the Ubuntu guide.

Now your development environment is almost ready. The only problem is every time when you open Ubuntu on Windows you have to start the PostgreSQL service & Redis server manually. Don’t worry we can have a workaround for this by creating a custom command :wink:

cd ~

Create a new file using the command nano start-discourse and paste the content below then save and exit.


# to start PostgreSQL
sudo service postgresql start

# to start Redis server
redis-server --daemonize yes

Now modify the CHMOD using below command

chmod +x start-discourse

And copy the file to your bin folder

sudo cp start-discourse /usr/bin/

It’s done. Now, whenever you open the Ubuntu bash just run the command below and start developing :+1:


Alternatively, if you are using Windows 10 enterprise, pro, or education edition then you can create a Linux virtual machine in hyper-v to set up the Discourse dev environment.

How to install Discourse on windows
Help installing Discourse for Developer
Beginners Guide to Install Discourse on Ubuntu for Development
Database connection error when setting up Discourse development environment using Linux Bash Shell on Windows 10
Restoring backup fails in Win10/Ubuntu development environment
Restoring backup fails in Win10/Ubuntu development environment
Importing Phorum to Discourse
Discourse Development Contribution Guidelines
Beginners Guide to Install Discourse on Ubuntu for Development
How to install on localhost
Importing MyBB to Discourse
WSL environment deadlocks
Problem with development on Windows with Docker and mounted volume
How can i install Discourse forum on my win 10 dedicated server OVH
Beginners Guide to Install Discourse for Development using Docker
Discourse eclipse in window
Beginners Guide to Install Discourse on Ubuntu for Development
Restoring backup fails in Win10/Ubuntu development environment
Topics which users cannot directly reply to, but can create a linked topic?
Importing NodeBB (Redis) to Discourse
Importing NodeBB (MongoDB) to Discourse
How to add a new language
How to Start Sidekiq When Using Puma
Discourse-webpack: A boilerplate for developing JS-heavy Discourse components
How can I directly edit Discourse database from a GUI?
Can't set up dev environment due to cppjieba_rb failing to install
How to Add Ngrok to Allowed Hosts
»vagrant up« hangs
Dev Category sidebar
Beginners Guide to Install Discourse on Ubuntu for Development
Discourse installation end to end on Windows Server 2016
Beginners Guide to Install Discourse on Ubuntu for Development
Beginners Guide to Install Discourse on Ubuntu for Development
No connection to db issue
Migrating to Discourse from another Forum software
How to Install Discourse on LocalHost in Windows?
How to Install Discourse on LocalHost in Windows?
Importing PunBB to Discourse

thanks you, very very helpful for me!


If I’m using an up to date Windows machine, what’s the best way to get Discourse running locally for development? Best I can tell, my options are:

  • Linux subsystem on Windows
  • Docker container
  • Traditional Linux VM

I’m leaning towards the Docker container option, but I wanted to make sure one of the options wasn’t vastly superior first.

1 Like

If you are feeling brave and are comfortable selecting the slow ring for insider builds I think WSL2 can work alright.

If not I would recommend traditional VM + docker for the easy path cause you will have more tooling.

Pure docker should work but leaves you with less flexibility.


What do you mean by this exactly?

By pure docker do you mean directly on Windows or on top of WSL2? Regarding the flexibility, what kind of limitations are there with this approach?

1 Like

WSL2 requires you select at least the slow ring per: Get the latest Windows features | Install Windows 10 Insider Preview

I mean LCOW / Hyper-V per: Docker Linux Containers on Windows (With Examples) | Docker Blog


I keep forgetting that WSL2 isn’t publicly available yet. I’m not going to get an insider version of Windows just for that, so I’ll look more into the docker option you linked to. Thanks!


I just installed this. Working great. How can use my machine as real server. In settings it says you are in development mode.

1 Like

Yes, it is for development purposes only. You should use our cloud installation guide for production.


Currently trying this for WSL 2 with Ubuntu 18.04 LTS

For command

bundle exec rake autospec

terminal displays

Randomized with seed 20757

and just sits. In checking task manager the CPU is at 0% and disk usage is at 0 MB/s and also just sits at those values and have not changed for more than a minute.

With a previous attempt (using WSL 1 which was a crash and burn) at installing I pressed Enter for the Randomized with NNN for a few other times and sometimes it continued and sometimes it appeared to abort the process.

So, should I just be patient, press Enter or do something else?


After waiting 30 minutes pressed Enter which resulted in

Randomized with seed 20757

The following specs have failed:

Running Rspec: ./spec/requests/application_controller_spec.rb:451


Randomized with seed 45044


At other times pressing Enter resulted in

Running Rspec: ./spec/requests/application_controller_spec.rb:451

No specs have failed yet! Aborting anyway

So as near as I can figure, one should only press Enter after

Randomized with seed NNN

and wait at any other time.


So at one point I just filled the input queue with about 20 Enters and now the single command is/has been running continuously for a few hours.

Is bundle exec rake autospec expected to end by itself or do I have to abort it?


Found answer to

Is bundle exec rake autospec expected to end by itself or do I have to abort it?


In the meantime you can abort the rspec command and start using your local Discourse instance for development. If you reached to that step, your setup should be fine.

Thank you Ctrl-C.


There should be a badge for this.


Nice to know

eric@WINDOWS-XYZ:~$ sudo lsof -i -P -n | grep LISTEN
ruby       3316     eric   14u  IPv4 407552      0t0  TCP (LISTEN)
ruby       3388     eric   14u  IPv4 407552      0t0  TCP (LISTEN)
ruby       3398     eric   14u  IPv4 407552      0t0  TCP (LISTEN)
ruby       3413     eric   14u  IPv4 407552      0t0  TCP (LISTEN)
ruby       3429     eric   14u  IPv4 407552      0t0  TCP (LISTEN)
postgres  11696 postgres    7u  IPv4 111221      0t0  TCP (LISTEN)
redis-ser 11717     eric    6u  IPv6 113241      0t0  TCP *:6379 (LISTEN)
redis-ser 11717     eric    7u  IPv4 113242      0t0  TCP *:6379 (LISTEN)

I’ve tried several ways to get this working but it keeps failing on the step for db create. It fails to connect to redis, even though redis-server is running in the WSL, I can connect with redis-cli, and execute commands. When I run db:create step, it fails with this error:

ti0:~/discourse > bundle exec rake db:create
rake aborted!
IO::EINPROGRESSWaitWritable: Operation now in progress - connect(2) would block
/home/ti0/discourse/app/models/global_setting.rb:42:in `safe_secret_key_base'=
/home/ti0/discourse/config/initializers/100-secret_token.rb:6:in `<main>'
/home/ti0/discourse/config/environment.rb:7:in `<main>'
/home/ti0/.rbenv/versions/2.7.1/bin/bundle:23:in `load'
/home/ti0/.rbenv/versions/2.7.1/bin/bundle:23:in `<main>'
Caused by:
IO::EINPROGRESSWaitWritable: Operation now in progress - connect(2) would block
/home/ti0/discourse/app/models/global_setting.rb:42:in `safe_secret_key_base'
/home/ti0/discourse/config/initializers/100-secret_token.rb:6:in `<main>'
/home/ti0/discourse/config/environment.rb:7:in `<main>'
/home/ti0/.rbenv/versions/2.7.1/bin/bundle:23:in `load'
/home/ti0/.rbenv/versions/2.7.1/bin/bundle:23:in `<main>'
Tasks: TOP => db:create => db:load_config => environment
(See full trace by running task with --trace)
ti0:~/discourse > top
22245 redis     20   0   46428   2240   1792 S   0.0  0.0   0:00.02 redis-server
22800 postgres  20   0  221240  19860  19804 S   0.0  0.0   0:00.51 postgres

ti0:~/discourse > redis-cli> ping

As of June 30, 2020:
With the introduction of Windows 10 build 2004 and WSL 2 and many of you might run into some issues since Discourse now requires WSL 2 to actually run.
For starters: If you haven’t already, you would want to update your system to Windows 2004 (19041)
Note: Don’t install using Windows Update in the system settings as you might get errors mid-installation. Also make sure you are on Windows 1903 (18362) or 1909 (18363), you can search winver for that.

  • Go to: Download Windows 10
  • Click the Update Now button under Windows 10 May 2020 Update to download the update assistant and let it intall and finish
  • If you get any errors, then download the media creation tool, run it, and create a bootable flash drive (at least 8GB flash) and use it to install Windows.

When you are done with the Windows installation, you will need to manually install WSL 2
But first, we need to make sure that 2 features are enabled:

  • Virtual Machine Platform which can be enabled directly from your Windows by going to Programs and Features and then enabling Optional Features in Turn Windows features on or off
  • The other is Virtualization which can be only enabled from your BIOS. However this option can vary from one motherboard to the other. eg: on AMD it’s called SVM. So please look up your specific motherboard.

Now that you have both features enabled:

  • Install Ubuntu 18.04, and not 20.04 since some installations will fail on 20.04.
  • Go here and update Linux Kernel: Link in replies
  • Go to this link and follow the steps: Install Windows Subsystem for Linux (WSL) on Windows 10 | Microsoft Docs
  • Go to powershell (run as administrator) and run: wsl --set-version Ubuntu-18.04 2 or wsl --set-version Ubuntu 2, whichever distro shows up in wsl -l -v
  • Conversion takes time, a few minutes
  • Run wsl -l -v to make sure that Ubuntu is running on WSL 2

Now you can run Ubuntu-18.04 or Windows Terminal with Ubuntu and start installing the dependencies and tools

Note: If you are running into an error installing one of the gems during bundle install: Make sure you are on Ubuntu-18.04 and not 20.04

However, if you already have postgreSQL 12 and running on port 5432, you might run into some issues, since the dependencies install postgreSQL 10, which might increment the port to 5433.
To fix that:

  • Open your folder in a text editor (VS Code for example)
  • Go to config/database.yml
  • Under development and under adapter, add a new line and then add: port: 5433
  • Make sure you do the same for test and profile.

If the above doesn’t work, make sure to check if PostgreSQL is running and at which port via pg_isready. Then follow the same instructions above, setting the port equal to the one the database is running on.


FOR THE LINUX KERNEL: Updating the WSL 2 Linux kernel | Microsoft Docs


Tested it out, build 1903 upgrade worked following these steps, build 1909 awaiting installation to complete.

UPDATE: build 1909 upgrade to 2004 has failed (it took away my login screen so I couldn’t log in)

Awaiting future updates and bug fixes on Microsoft’s end to solve this issue.
In the meantime, I’m switching to solely Ubuntu.


Thanks so much! This was driving me insane


this fixed my issue, I can confirm it works! thank you so much ! :green_heart:


As of July 1, 2020:
A solution that does not require explicit port configuration in database.yml

Some errors during database creation and migration:

Invalid Redis connection to a specific port / connection refusal

$ bundle exec rake db:create
rake aborted!
Redis::CannotConnectError: Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)

Caused by:
Errno::ECONNREFUSED: Connection refused - connect(2) for

Caused by:
IO::EINPROGRESSWaitWritable: Operation now in progress - connect(2) would block

Tasks: TOP => db:create => db:load_config => environment
(See full trace by running task with --trace)

From this error we can see that the port Redis uses is 6379, and we can fix this by starting the Redis server via that port.

By default, redis-server --daemonize yes should work, but if not, use:

$ redis-server --daemonize yes --port 6379

Check status of Redis instance:

$ redis-cli> ping

Invalid connection to psql port

$ bundle exec rake db:migrate
PG::ConnectionBad: could not connect to server: No such file or directory
       Is the server running locally and accepting
       connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

From this error we can see that PostgreSQL is having trouble connecting to port 5432. Usually starting the service should work

sudo service postgresql start

If this still doesn’t work and the error persists, try checking to see which port the service is listening from, and if necessary, change the port to the one you want in postgresql.conf:

$ pg_isready
/var/run/postgresql:5432 - no response
/var/run/postgresql:5432 - accepting connections

The Result

Once we have done the above or executed the start-discourse command, the two instances should run on their default/specified ports. To check their status via the default Windows cmd terminal, we can run:

netstat -anop tcp

which will show something like this:

Proto    Local Address        Foreign Address        State            PID
TCP              LISTENING        17768
TCP              LISTENING        17768

We have now confirmed that both our postgresql and redis-server instances are running.

We can also check the status of the instances on Ubuntu or WSL, with the following commands:

lsof -i
mailcatch  3244  rickyc0626  7u  IPv4   36127       0t0   TCP  localhost:1025 (LISTEN)
mailcatch  3244  rickyc0626  8u  IPv4   36128       0t0   TCP  *:socks (LISTEN)
redis-ser  3287  rickyc0626  6u  IPv6   29352       0t0   TCP  *:6379 (LISTEN)
redis-ser  3287  rickyc0626  7u  IPv6   29353       0t0   TCP  *:6379 (LISTEN)

sudo ss -plunt | grep postgres
tcp  LISTEN  0  128*  users:(("postgres",pid=3070,fd=7))

Ver Cluster Port Status Owner    Data directory              Log file
10  main    5432 online postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log

From here, these commands should work with no major issues, without needing to modify the database.yml file:

bundle exec rake db:create 
bundle exec rake db:migrate
RAILS_ENV=test bundle exec rake db:create db:migrate

Any further issues that show up can be addressed in the future.


I am able to run this with WSL2 and it’s whole lot faster than WSL1.

Question though: Anyone successfully expose the instance to local network? (to test out on mobile on the same WiFi). I am cracking my head to make it work, disabled firewall, listen to all interface but still no luck what could I had missed? My phone resolves “Err connection refuse” while trying to connect to my host PC’s ip at port 3000.

And this is for plugin development right? If I wanted to set things up for my new forum, what should the workflow be like? Can I migrate the backup from my local ubuntu to docker on Digital Ocean later on? What will be lost/kept?


Did you try by binding the rails server to all IP addresses ( Anyway in the desktop, you can force the application to mobile view by adding the query string ?mobile_view=1.

Yes, you can. It will copy everything from the database.


Yup, done that. I switched to Docker Dev and launch it with -p, still no luck. I have finally resort to using the mobile view in my browser.

I tested this out too, so far I think I got what I needed, i.e. categories, topics, etc.


1 Like