Beginners Guide to Install Discourse on Ubuntu for Development

Looks like you are not running posgres to me, did you follow all the PG steps correctly?

If you are getting stuck I SUPER HIGHLY recommend you try this:


I tried docker, but it shows this
root@WINDOWS-G5B317T:~/discourse# ./bin/docker/boot_dev --init
Using source in: /home/dev/discourse
Using data in: /home/dev/discourse/data/postgres
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See ‘docker run --help’.
root@WINDOWS-G5B317T:~/discourse# docker run daemon
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See ‘docker run --help’.
root@WINDOWS-G5B317T:~/discourse# systemctl start docker
System has not been booted with systemd as init system (PID 1). Can’t operate.

how to solve that?? I tried many ways but can’t solve this issue
Thank you for your help

:thinking: do you have docker installed.


Hi guys, I got this error when I execute this:

xxx@DESKTOP-LICQPFO:~/discourse$ bundle exec rake db:create db:migrate
Discourse requires Ruby 2.5.2 or up

ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]

I updated ruby to 2.5.3 but then I got another error when I run bundle install:

Warning: the running version of Bundler (1.16.1) is older than the version that created the lockfile (1.17.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.

Fetching gem metadata from
Using rake 12.3.1
Using concurrent-ruby 1.0.5
Using i18n 1.0.1
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.2.0
Using builder 3.2.3
Using erubi 1.7.1
Using mini_portile2 2.3.0
Fetching nokogiri 1.8.5
Installing nokogiri 1.8.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/xxxx/discourse/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.8.5/ext/nokogiri
/usr/bin/ruby2.5 -r ./siteconf20181111-13645-a4zobf.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /home/xxxx/discourse/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.8.5 for
Results logged to

An error occurred while installing nokogiri (1.8.5), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.8.5'` succeeds before bundling.

In Gemfile:
  actionmailer was resolved to 5.2.0, which depends on
    actionpack was resolved to 5.2.0, which depends on
      actionview was resolved to 5.2.0, which depends on
        rails-dom-testing was resolved to 2.0.3, which depends on

I ran gem install bundler nothing changes, I still have the warning message saying Warning: the running version of Bundler (1.16.1) is older than the version that created the lockfile

I ran gem install nokogiri -v ‘1.8.5’ but it generated another error:

xxxx@DESKTOP-LICQPFO:~/discourse$ gem install nokogiri -v '1.8.5'

Building native extensions. This could take a while...

/home/xxxx/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/ext/builder.rb:76: warning: Insecure world writable dir /home/xxxx/.rbenv/versions in PATH, mode 040777

Any help would be appreciated, thanks.

nokogiri can be rather difficult to install as it compiles a bunch of dependencies which are theoretically bundled see: GitHub - sparklemotion/nokogiri: Nokogiri (鋸) is a Rubygem providing HTML, XML, SAX, and Reader parsers with XPath and CSS selector support.

Looking at that warning I am not seeing the actual error, are you sure this is all you have?

I would strongly recommend just going with our docker based dev environment to avoid a lot of this pain: discourse/bin/docker at master · discourse/discourse · GitHub

1 Like

For anyone that does not know how to restart postgres you can use the following command (I had to run this with sudo):

$ sudo service postgresql restart


This topic is meant for Discourse on a native Ubuntu install. If you are using WSL, you need to use this method:


A post was merged into an existing topic: Beginners Guide to Install Discourse on Windows 10 for Development


I have an issue at the step bellow.

I have this message

root@dsff2:~/discourse# sudo -u postgres createuser -s dada
could not change directory to "/root/discourse": Permission denied

I don’t know wich user I have to use … I have only the root user. I didn’t created any other user.

Have you solved this? I’m getting the same warning and error about nokogiri.

Hi guy i am getting method ‘sub’ for nill class after installing discourse and setting up admin password and email

Have you tried our docker based dev environment:


I’ve created a GNU screen file for Discourse. After running sudo apt install screen to install the program, you can paste the below into a file named ubuntu.screen in your user’s home directory and execute the commands in the file’s comments.

# GNU screen configuration file for Discourse Ubuntu development

# Start up your development instance in detached mode:
#   screen -d -m -c ~/ubuntu.screen

# Start in attached mode:
# screen -m -c ~/ubuntu.screen

# commands that exit hang around until you hit 'k' to kill or 'r' to restart
zombie kr

screen -t rails_s 0 bash -c 'echo Starting rails server...;  cd ~/discourse; bundle exec rails s -b'
screen -t rails_c 1 bash -c 'echo Starting rails console...; cd ~/discourse; bundle exec rails c'
screen -t mail    2 bash -c 'echo Starting mailcatcher...;   cd ~/discourse; mailcatcher --http-ip'

scrollback 50000

Does someone know what is the problem and how to solve it?

Unpacking libjpeg-turbo-progs (1.5.2-0ubuntu5.18.04.1) …
Selecting previously unselected package jhead.
Preparing to unpack …/jhead_1%3a3.00-8~build0.18.04.1_amd64.deb …
Unpacking jhead (1:3.00-8~build0.18.04.1) …
Setting up libjpeg-turbo-progs (1.5.2-0ubuntu5.18.04.1) …
Setting up jhead (1:3.00-8~build0.18.04.1) …
Processing triggers for man-db (2.8.3-2) …

Installing Ruby 2.6.1 …

/dev/fd/63: line 68: rbenv: command not found


For future developers, the solution was to deactivate temporary the Avira antivirus.
Good luck!

Did you modify your path? There is a step where you add to bashrc and source it you might log out and back in or just open a new terminal.

I solved to problem and updated my comment with the solution. Thank you for your help :slight_smile:

1 Like

I’m getting the following error:

It appears to be a postgres connection issue. The log file says that it’s

listening on Unix socket "/var/run/postgresql/.s.PGSQL.5443"

This looks like WSL to me… I think you need to start the postgres service systemctl start postgresql probably. Same goes for starting redis.

1 Like

Both postgres and redis appear to be running from what I can tell.


And when I do redis-cli ping, it returns PONG

Is the socket file there? Maybe you had pg on win10 so it picked a different port?