# How to allow customs hosts in development mode

**URL:** https://meta.discourse.org/t/how-to-allow-customs-hosts-in-development-mode/129958
**Category:** Development
**Created:** [October 1, 2019, 2:45pm UTC](https://meta.discourse.org/t/how-to-allow-customs-hosts-in-development-mode/129958 "2019-10-01T14:45:56Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mompo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mompo/32/157564_2.png) [@mompo](https://meta.discourse.org/u/mompo)
#### Post date: [October 1, 2019, 2:45pm UTC](https://meta.discourse.org/t/how-to-allow-customs-hosts-in-development-mode/129958/1 "2019-10-01T14:45:57Z")

</div>

Hi.

I’m new to discourse and started diving into it by setting up a development system, following [this](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-ubuntu-for-development/14727) howto.  
Afterwards I was able to access my instance via ip address, but trying to access via hostname fails with following message:

> Blocked host: discourse\_example\_net  
> To allow requests to discourse\_example\_net, add the following to your environment configuration:  
> config.hosts \<\< “discourse\_example\_net”

I found [this PR](https://review.discourse.org/t/dev-allow-custom-hosts-in-development-mode/5668), but I don’t know how to set the env var.

Best,  
Luis

---

<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: [October 2, 2019, 1:57pm UTC](https://meta.discourse.org/t/how-to-allow-customs-hosts-in-development-mode/129958/2 "2019-10-02T13:57:41Z")

</div>

You can prepend `DISCOURSE_DEV_HOSTS=discourse_example_net` to the command that starts the unicorn server, or you can set the variable in your `~/.bashrc` (or the rc file of the shell you use).

---

<div class="post-metadata">

### Author: ![Stanzilla](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stanzilla/32/166422_2.png) [@Stanzilla](https://meta.discourse.org/u/Stanzilla)
#### Post date: [January 14, 2020, 3:39pm UTC](https://meta.discourse.org/t/how-to-allow-customs-hosts-in-development-mode/129958/3 "2020-01-14T15:39:04Z")

</div>

I tried `DISCOURSE_DEV_HOSTS=xxx.ngrok.io d/unicorn` and it did not work, sadly

---

<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: [January 15, 2020, 5:40am UTC](https://meta.discourse.org/t/how-to-allow-customs-hosts-in-development-mode/129958/4 "2020-01-15T05:40:56Z")

</div>

I’m assuming you mean by “did not work” you still got the same error as the OP? It looks like you’re using docker for development, so you need to set this environment variable inside the container, not the host machine. I don’t use docker for development, but it looks like `d/boot_dev` can set variables inside the container for you:

```plaintext
d/boot_dev -e DISCOURSE_DEV_HOSTS=xxx.ngrok.io

```

And then run `d/unicorn`.

---

<div class="post-metadata">

### Author: ![Stanzilla](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stanzilla/32/166422_2.png) [@Stanzilla](https://meta.discourse.org/u/Stanzilla)
#### Post date: [January 15, 2020, 9:22am UTC](https://meta.discourse.org/t/how-to-allow-customs-hosts-in-development-mode/129958/5 "2020-01-15T09:22:14Z")

</div>

That always ends up in

```plaintext
502 Bad Gateway
The server returned an invalid or incomplete response.

```
