# Can't reach Discourse server in VM from Host

**URL:** https://meta.discourse.org/t/cant-reach-discourse-server-in-vm-from-host/154151
**Category:** Development
**Created:** [June 8, 2020, 5:12am UTC](https://meta.discourse.org/t/cant-reach-discourse-server-in-vm-from-host/154151 "2020-06-08T05:12:32Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Hugo\_Lol](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hugo_lol/32/154430_2.png) [@Hugo\_Lol](https://meta.discourse.org/u/Hugo_Lol)
#### Post date: [June 8, 2020, 5:12am UTC](https://meta.discourse.org/t/cant-reach-discourse-server-in-vm-from-host/154151/1 "2020-06-08T05:12:32Z")

</div>

Hello there! I’ve successfully installed Discourse in an Ubuntu 18.04 virtual machine (using VMware Workstation 15 Player) following [the guide](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-ubuntu-for-development/14727). 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:

```plaintext
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:

```plaintext
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?

Thanks in advance!

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [June 8, 2020, 7:23am UTC](https://meta.discourse.org/t/cant-reach-discourse-server-in-vm-from-host/154151/2 "2020-06-08T07:23:56Z")

</div>

> [@Hugo\_Lol](#):
>
> VMware Workstation

Hello @Hugo_Lol

You might find it helpful to review how to set up port forwarding between a host and a VM, for example:

[https://www.howtogeek.com/122641/how-to-forward-ports-to-a-virtual-machine-and-use-it-as-a-server/](https://www.howtogeek.com/122641/how-to-forward-ports-to-a-virtual-machine-and-use-it-as-a-server/)

Another example:

> **[How to Setup Port Forwarding in VMware Workstation 9 | virten.net](https://www.virten.net/2013/03/how-to-setup-port-forwarding-in-vmware-workstation-9/)**

Maybe you can use these examples to give you an idea how to get started solving this?

Hope this helps.

---

<div class="post-metadata">

### Author: ![Hugo\_Lol](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hugo_lol/32/154430_2.png) [@Hugo\_Lol](https://meta.discourse.org/u/Hugo_Lol)
#### Post date: [June 8, 2020, 1:36pm UTC](https://meta.discourse.org/t/cant-reach-discourse-server-in-vm-from-host/154151/3 "2020-06-08T13:36:32Z")

</div>

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… 🤔

Any ideas?

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [June 8, 2020, 2:19pm UTC](https://meta.discourse.org/t/cant-reach-discourse-server-in-vm-from-host/154151/4 "2020-06-08T14:19:34Z")

</div>

Hey @Hugo_Lol,

You are welcome.

I am not a Windows user so I cannot be of much further help, sorry about that!

The best suggestion I have is to look for clues in the various Discourse logfiles in `/var/log`.

---

<div class="post-metadata">

### Author: ![Osama](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osama/32/98013_2.png) [@Osama](https://meta.discourse.org/u/Osama)
#### Post date: [June 8, 2020, 2:43pm UTC](https://meta.discourse.org/t/cant-reach-discourse-server-in-vm-from-host/154151/5 "2020-06-08T14:43:44Z")

</div>

> [@Hugo\_Lol](#):
>
> `bundle exec rails server --binding=0.0.0.0`

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):

```plaintext
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`.

---

<div class="post-metadata">

### Author: ![Hugo\_Lol](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hugo_lol/32/154430_2.png) [@Hugo\_Lol](https://meta.discourse.org/u/Hugo_Lol)
#### Post date: [June 8, 2020, 4:50pm UTC](https://meta.discourse.org/t/cant-reach-discourse-server-in-vm-from-host/154151/6 "2020-06-08T16:50:23Z")

</div>

> [@Osama](#):
>
> So this should work: `UNICORN_BIND_ALL=1 bundle exec rails server` .

That did the trick! It’s working now. Thank you both a lot. 👏

---

<div class="post-metadata">

### Author: ![shell](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shell/32/208151_2.png) [@shell](https://meta.discourse.org/u/shell)
#### Post date: [February 2, 2021, 8:13pm UTC](https://meta.discourse.org/t/cant-reach-discourse-server-in-vm-from-host/154151/7 "2021-02-02T20:13:51Z")

</div>

> [@Osama](#):
>
> So this should work: `UNICORN_BIND_ALL=1 bundle exec rails server`

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

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 3, 2021, 1:06am UTC](https://meta.discourse.org/t/cant-reach-discourse-server-in-vm-from-host/154151/8 "2021-02-03T01:06:47Z")

</div>

Absolutely, you can do so yourself! it is a wiki 👍🏼

---

<div class="post-metadata">

### Author: ![Justman10000](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justman10000/32/252913_2.png) [@Justman10000](https://meta.discourse.org/u/Justman10000)
#### Post date: [October 20, 2022, 10:15pm UTC](https://meta.discourse.org/t/cant-reach-discourse-server-in-vm-from-host/154151/9 "2022-10-20T22:15:10Z")

</div>

> [@Osama](#):
>
> 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 bro! Had the same problem, this fixed it!
