# Setting the koyo port

**URL:** https://racket.discourse.group/t/setting-the-koyo-port/1103
**Category:** Questions & Answers
**Tags:** koyo
**Created:** [June 29, 2022, 1:02pm UTC](https://racket.discourse.group/t/setting-the-koyo-port/1103 "2022-06-29T13:02:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![robertpostill](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/robertpostill/32/53_2.png) [@robertpostill](https://racket.discourse.group/u/robertpostill)
#### Post date: [June 29, 2022, 1:02pm UTC](https://racket.discourse.group/t/setting-the-koyo-port/1103/1 "2022-06-29T13:02:46Z")

</div>

I have a couple of forms in my config.rkt that I believe set the IP and port of the racket web server:

```scheme
(define-option http-host #:default "127.0.0.1")
(define-option http-port #:default (or (getenv "PORT") "8000")
  (string->number http-port))

(define-option url-scheme #:default "http"
  (begin0 url-scheme
    (current-application-url-scheme url-scheme)))

(define-option url-host #:default "127.0.0.1"
  (begin0 url-host
    (current-application-url-host url-host)))

(define-option url-port #:default (or (getenv "PORT") "8000")
  (begin0 url-port
    (current-application-url-port (string->number url-port))))

```

Both `http-port` and `url-port` are driven from the \<APP\_NAME\>\_PORT env var. Which I haven't set in my .env file.

However when I do a `raco chief start` I get the following:

```scheme
22:39:00 web.1 | [2022-06-29 22:39:00.057] [8894] [debug] system: starting component server
22:39:00 web.1 | [2022-06-29 22:39:00.058] [8894] [info] server: listening on 127.0.0.1:5100
22:39:00 web.1 | [2022-06-29 22:39:00.062] [8880] [info] runner: application process started with pid 8894

```

And sure enough, I can get a login from [http://127.0.0.1:5100](http://127.0.0.1:5100) but the default is 8000? What am I missing about koyo port configuration?

---

<div class="post-metadata">

### Author: ![bogdan](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/bogdan/32/8_2.png) [@bogdan](https://racket.discourse.group/u/bogdan)
#### Post date: [June 29, 2022, 1:22pm UTC](https://racket.discourse.group/t/setting-the-koyo-port/1103/2 "2022-06-29T13:22:14Z")

</div>

Chief tries to be helpful by assigning every service in your `Procfile` a unique port number. It does this by inserting a `PORT` environment variable into the environment of every spawned process. I see this isn't mentioned in the documentation for chief so I'll have to fix that.

You can ignore this behavior by changing

```scheme
(define-option http-port #:default (or (getenv "PORT") "8000")
  (string->number http-port))

```

to

```scheme
(define-option http-port #:default "8000"
  (string->number http-port))

```

Ditto for the `url-port`.

Alternatively, if you add an `APP_NAME_PORT` entry to your `.env` file, that'll take precedence.

---

<div class="post-metadata">

### Author: ![robertpostill](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/robertpostill/32/53_2.png) [@robertpostill](https://racket.discourse.group/u/robertpostill)
#### Post date: [June 29, 2022, 11:39pm UTC](https://racket.discourse.group/t/setting-the-koyo-port/1103/3 "2022-06-29T23:39:01Z")

</div>

Thanks. While I'm thinking about it can I ask what the difference between `url-port` and `http-port` is?

---

<div class="post-metadata">

### Author: ![bogdan](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/bogdan/32/8_2.png) [@bogdan](https://racket.discourse.group/u/bogdan)
#### Post date: [June 30, 2022, 5:26am UTC](https://racket.discourse.group/t/setting-the-koyo-port/1103/4 "2022-06-30T05:26:12Z")

</div>

The `http-{host,port}` options determine what host and port the server listens on and the `url-{scheme,host,port}` influence the output of [make-application-url](https://docs.racket-lang.org/koyo/url.html#%28part._.Application_.U.R.Ls%29).

---

<div class="post-metadata">

### Author: ![robertpostill](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/robertpostill/32/53_2.png) [@robertpostill](https://racket.discourse.group/u/robertpostill)
#### Post date: [July 1, 2022, 6:14am UTC](https://racket.discourse.group/t/setting-the-koyo-port/1103/5 "2022-07-01T06:14:31Z")

</div>

cool, so they'd diverge if you were say behind a reverse proxy. In which case the url-{scheme, host, port} would then point to the proxy. Got it, thanks 👍
