# Changing the Guardfile leads to "Address already in use"

**URL:** <https://discourse.hanakai.org/t/changing-the-guardfile-leads-to-address-already-in-use/808>\
**Category:** general\
**Created:** [March 12, 2023, 3:35pm UTC](https://discourse.hanakai.org/t/changing-the-guardfile-leads-to-address-already-in-use/808 "2023-03-12T15:35:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Signum](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Signum](https://discourse.hanakai.org/u/Signum)\
**Post date:** [March 12, 2023, 3:35pm UTC](https://discourse.hanakai.org/t/changing-the-guardfile-leads-to-address-already-in-use/808/1 "2023-03-12T15:35:04Z")

</div>

I found that changing/touching the Guardfile breaks the guard run.

First run of “hanami server” → all works as expected.

Touching/changing the Guardfile leads to:

16:24:38 - WARN - Guardfile changed – \_guard-core will exit.  
16:24:38 - INFO - Using Guardfile at /home/…/hanami/Guardfile.  
16:24:38 - INFO - Puma starting on port 2300 in development environment.  
[45593] Puma starting in cluster mode…  
[45593] \* Puma version: 6.1.1 (ruby 3.2.0-p0) (“The Way Up”)  
[45593] \* Min threads: 5  
[45593] \* Max threads: 5  
[45593] \* Environment: development  
[45593] \* Master PID: 45593  
[45593] \* Workers: 2  
[45593] \* Restarts: (✔) hot (✖) phased  
[45593] \* Preloading application  
/home/…/hanami/vendor/bundle/ruby/3.2.0/gems/puma-6.1.1/lib/puma/binder.rb:335:in `initialize’: Address already in use - bind(2) for “0.0.0.0” port 2300 (Errno::EADDRINUSE)  
[…]  
16:24:39 - INFO - Guard is now watching at ‘/home/…/hanami’

I then have to stop (Ctrl-C) the server process and restart it.

Pretty sure this is not a Hanami bug but somewhere in Puma or Guard. I could not find anything in Puma or Guard issues that explains it. But it affects new Hanami projects as well. Does anyone have an idea what causes this?

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [March 13, 2023, 9:34am UTC](https://discourse.hanakai.org/t/changing-the-guardfile-leads-to-address-already-in-use/808/2 "2023-03-13T09:34:29Z")

</div>

@Signum Help me to understand. Do you do the following?

1. Run `hanami server`
2. While the server is running, you modify the `Guardfile.`
3. You get the `Errno::EADDRINUSE` error

If that is the case, between steps 1 and 2, you should stop the server, modify the `Guardfile`, then start the server again.

This is how Guard works.

---

<div class="post-metadata">

**Author:** ![Signum](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Signum](https://discourse.hanakai.org/u/Signum)\
**Post date:** [March 13, 2023, 1:47pm UTC](https://discourse.hanakai.org/t/changing-the-guardfile-leads-to-address-already-in-use/808/3 "2023-03-13T13:47:40Z")

</div>

Yes, that’s what I’m doing. If that’s by design and Guard doesn’t like it then I’ll stop/start it while I’m doing changes. I just wondered because Guard is restarting automatically whenever the Guardfile changes. So it felt like something that is supposed to work.

Thanks for the explanation.

---

<div class="post-metadata">

**Author:** ![bkuhlmann](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/bkuhlmann/32/475_2.png) [@bkuhlmann](https://discourse.hanakai.org/u/bkuhlmann)\
**Post date:** [March 13, 2023, 6:14pm UTC](https://discourse.hanakai.org/t/changing-the-guardfile-leads-to-address-already-in-use/808/4 "2023-03-13T18:14:02Z")

</div>

💡 You can also use [Rerun](https://github.com/alexch/rerun) + [Overmind](https://github.com/DarthSim/overmind) which makes for nice workflow without having to worry about restarting the server each time you make a change. Usage is documented in this [Hanami demonstration project](https://github.com/bkuhlmann/hemo#usage) and here’s the code from the [Procfile](https://github.com/bkuhlmann/hemo/blob/main/Procfile.dev) of that same project if you need it.

---

<div class="post-metadata">

**Author:** ![timriley](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/timriley/32/621_2.png) [@timriley](https://discourse.hanakai.org/u/timriley)\
**Post date:** [March 13, 2023, 9:38pm UTC](https://discourse.hanakai.org/t/changing-the-guardfile-leads-to-address-already-in-use/808/5 "2023-03-13T21:38:22Z")

</div>

IMO, this honestly sounds like a bug worth reporting to [guard-puma](https://github.com/jc00ke/guard-puma). I’d definitely encourage you to find a minimal reproduction (i.e. single rackup file only, no Hanami) and share it there.
