# Change unicorn port from 3000 in development

**URL:** https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737
**Category:** Development
**Created:** [14 augustus 2018 om 18:07 UTC](https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737 "2018-08-14T18:07:53Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![typeoneerror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/typeoneerror/32/80817_2.png) [@typeoneerror](https://meta.discourse.org/u/typeoneerror)
#### Post date: [14 augustus 2018 om 18:07 UTC](https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737/1 "2018-08-14T18:07:54Z")

</div>

A recent [commit](https://github.com/discourse/discourse/commit/81c68491941bb7ac8760bd020e7e361acd0501bc) changed the “unicorn port” from 9292 to 3000. I don’t see any way to change the port now and this is confliciting with another rails site I have running on 3000. Previously, I’ve been running discourse as `bundle exec rails server --port=3001`, but this no longer works as unicorn is now grabbing 3000.

Tried a few combinations of `UNICORN_PORT=3001`, `--port=3001`, changing source code of `unicorn.conf`, but end up with:

> I, [2018-08-14T11:26:11.496753 #63852] INFO – : listening on addr=0.0.0.0: **3000** fd=20

Each time.

Any way to work around this?

---

<div class="post-metadata">

### Author: ![typeoneerror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/typeoneerror/32/80817_2.png) [@typeoneerror](https://meta.discourse.org/u/typeoneerror)
#### Post date: [14 augustus 2018 om 18:34 UTC](https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737/2 "2018-08-14T18:34:22Z")

</div>

Changed that line in `bin/rails` to point to 3001 and it seems to work now. Should that line be an `||=`?

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [14 augustus 2018 om 22:28 UTC](https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737/3 "2018-08-14T22:28:42Z")

</div>

Why do you have another Rails site running in the same container as Discourse?

---

<div class="post-metadata">

### Author: ![typeoneerror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/typeoneerror/32/80817_2.png) [@typeoneerror](https://meta.discourse.org/u/typeoneerror)
#### Post date: [14 augustus 2018 om 22:43 UTC](https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737/4 "2018-08-14T22:43:01Z")

</div>

Donno, Matt. I followed [Install Discourse on macOS for development](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-macos-for-development/15772) which didn’t have me setting up containers (I’m assuming you’re referring to Docker or something related?).

---

<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: [15 augustus 2018 om 00:38 UTC](https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737/5 "2018-08-15T00:38:56Z")

</div>

> [@typeoneerror](#):
>
> Any way to work around this?

There are 2 schools of thought when it comes to launching a `rails server` in development.

The @sam school of thought, where you want to keep console pristine cause you are a fanatical [puts debugger](https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html). That way you can just add `puts` statements around the app and see the output in the same window you run the server.

If you subscribe to @sam’s school of thought you launch your rails server with:

```plaintext
bin/unicorn

```

If you want a different port, you run

```plaintext
bin/unicorn -p 7777

```

The other school of thought is the @tgxworld school of thought / Rails official setup. In this case are not a puts debugger and want to see **all the debug rails logs** in the console.

If you are like this you would launch unicorn in dev via

```plaintext
bin/rails s

```

If you want a custom port you will use

```plaintext
bin/rails s -p 7777

```

Note, I had to push a few fixes to make this post true, so pull latest.

---

<div class="post-metadata">

### Author: ![typeoneerror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/typeoneerror/32/80817_2.png) [@typeoneerror](https://meta.discourse.org/u/typeoneerror)
#### Post date: [15 augustus 2018 om 17:23 UTC](https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737/6 "2018-08-15T17:23:58Z")

</div>

> [@sam](#):
>
> Note, I had to push a few fixes to make this post true, so pull latest.

You rock, @sam, cheers!

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [15 augustus 2018 om 18:56 UTC](https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737/7 "2018-08-15T18:56:23Z")

</div>

Or you subscribe to @LeoMcA’s school of thought, where you’re a fanatical puts debugger, but launch with `rails s`, so you have to squint really hard to see what you want among all the rails logs.

I feel like a fool.

---

<div class="post-metadata">

### Author: ![typeoneerror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/typeoneerror/32/80817_2.png) [@typeoneerror](https://meta.discourse.org/u/typeoneerror)
#### Post date: [15 augustus 2018 om 19:13 UTC](https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737/8 "2018-08-15T19:13:39Z")

</div>

Yeah, I launch my local dev with Puma via Foreman so I think I get “puts” in the Foreman logs and “logger.log” in the Rails log, so I think I’m with the @sam school in my other project. Nice to have these two schools for Discourse local dev now!

---

<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: [4 februari 2019 om 04:06 UTC](https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737/9 "2019-02-04T04:06:32Z")

</div>

FYI, foreman support has just been removed per:

[https://review.discourse.org/t/dev-remove-foreman-gem-and-unsupported-procfile/1485](https://review.discourse.org/t/dev-remove-foreman-gem-and-unsupported-procfile/1485)

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [6 december 2019 om 16:24 UTC](https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737/10 "2019-12-06T16:24:41Z")

</div>

> [@LeoMcA](#):
>
> Or you subscribe to @LeoMcA’s school of thought, where you’re a fanatical puts debugger, but launch with `rails s` , so you have to squint really hard to see what you want among all the rails logs.

I just [added an option](https://github.com/discourse/discourse/commit/78969d77199f51395c07a04c35a18bdb5ac8b87c) to avoid all that squinting, you can now use

```plaintext
DISCOURSE_DEV_LOG_LEVEL="warn" bin/rails s

```

to see puts statements locally without the noise.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [6 december 2019 om 16:38 UTC](https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737/11 "2019-12-06T16:38:29Z")

</div>

Nice! I’ve been using `RAILS_LOGS_STDOUT=0 rails s`, but this allows showing warnings/errors rather than binning everything 😍

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [26 februari 2021 om 08:52 UTC](https://meta.discourse.org/t/change-unicorn-port-from-3000-in-development/94737/12 "2021-02-26T08:52:08Z")

</div>

> [@sam](#):
>
> If you subscribe to @sam’s school of thought you launch your rails server with:

I’m starting to incline towards this school of thought lately 😉
