Hello there! I’ve successfully installed Discourse in an Ubuntu 18.04 virtual machine (using VMware Workstation 15 Player) following the guide. Access to http://localhost:3000/ from inside the VM goes well, but I can’t reach it from my Windows 10 host system. The VM network is configured in bridged mode, and for executing the rails server I’m running:
bundle exec rails server --binding=0.0.0.0
However, when I go to http://192.168.0.172:3000/ from my host machine, I get a connection refused error. I’ve tried setting up a simple Python HTTP server inside the VM:
python3 -m http.server 3000
And I can effectively reach it from my host machine, so I think this is Discourse-specific. Am I missing something?
Hi @neounix, thanks for the reply. I’ve already configured the VM network in bridged mode, and I can reach it from the outside using a simple Python HTTP server that listens in the same port (3000) and address (0.0.0.0), but for some reason it doesn’t work with the Discourse server…
The problem here is that the --binding option is completely ignored. I tried your command locally and I spotted this line in the output (the output is very noisy so it’s very easy to miss this line):
I, [2020-06-08T17:26:55.938086 #21001] INFO -- : listening on addr=127.0.0.1:3000 fd=15
Reading through our config/unicorn.conf.rb, to make the server listen to 0.0.0.0 you’ll need to set the UNICORN_BIND_ALL=1 environment variable. So this should work: UNICORN_BIND_ALL=1 bundle exec rails server.
Alternatively, you can use the bin/unicorn script which does accept a --host option that you can use to bind to 0.0.0.0.
Thanks, this saved me some headache.
I wonder if you can update official user guides to include this instead of non working solution with bundle exec rails server -b 0.0.0.0.
I saw it all over the internet and couldn’t imagine that it would not work