# Set up a multisite development environment

**URL:** https://meta.discourse.org/t/set-up-a-multisite-development-environment/229310
**Category:** Developer Guides
**Tags:** dev-install, how-to
**Created:** [June 7, 2022, 4:01pm UTC](https://meta.discourse.org/t/set-up-a-multisite-development-environment/229310 "2022-06-07T16:01:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [June 7, 2022, 4:01pm UTC](https://meta.discourse.org/t/set-up-a-multisite-development-environment/229310/1 "2022-06-07T16:01:37Z")

</div>

It’s possible to run discourse in multisite mode in development. A multisite server uses a different DB and hostname for each site that it serves. This is useful if you are developing a feature or a plugin that should be multisite compatible.

All you need to do is add an appropriate `config/multisite.yml` file. i.e:

```yaml
---
alternate:
  adapter: postgresql
  database: discourse_alternate
  host_names:
    - alternate.localhost

```

To run rake tasks against these extra sites, simply add the `RAILS_DB` environment variable with the name of the site that you are targeting:

```sh
RAILS_DB=alternate rake db:create
RAILS_DB=alternate rake db:migrate

```

Some rake tasks are special in that, when RAILS\_DB isn’t specified in development, they run across all sites:

```sh
rake db:create
rake db:migrate

```

_In general, however, running rake tasks without `RAILS_DB` set will target the default site._

To access the site, start the dev server:

```sh
bin/dev

```

You may now be able to view the your new site at [http://alternate.localhost:3000](http://alternate.localhost:3000), but if you cannot, you may need to add `alternate.localhost` to your `/etc/hosts` file or equivalent.

* * *

This document is version controlled - suggest changes [on github](https://github.com/discourse/discourse/blob/main/docs/developer-guides/docs/02-development-environments/09-multisite-setup.md).
