# How to stop a server created using Mux?

**URL:** <https://discourse.julialang.org/t/how-to-stop-a-server-created-using-mux/2380>\
**Category:** General Usage\
**Created:** [March 1, 2017, 1:10pm UTC](https://discourse.julialang.org/t/how-to-stop-a-server-created-using-mux/2380 "2017-03-01T13:10:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sarvjeet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sarvjeet/32/666_2.png) [@Sarvjeet](https://discourse.julialang.org/u/Sarvjeet)\
**Post date:** [March 1, 2017, 1:10pm UTC](https://discourse.julialang.org/t/how-to-stop-a-server-created-using-mux/2380/1 "2017-03-01T13:10:17Z")

</div>

Eg :

```julia
using Mux

@app test = (
  Mux.defaults,
  page(respond("<h1>Yo!</h1>")),
  page("/about", probabilty(0.5, respond("<h1>Boo tati!</h1>")),
  respond("<h1>About Me</h1>")),
  page("/user/:user", req -> "<h1>Hello, $(req[:params][:user])!</h1>"),
  Mux.notfound())

  #route("/about", respond("<h1>Hello World!</h1>")),
  #route("/prince", respond("<h1>Hello Prince!</h1>")),

serve(test)

```

How to stop this server ? So that I can create a new one at the same address. Now, if I try to create a new without stopping current one it raises an error - **listen: address already in use (EADDRINUSE)**.

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [March 1, 2017, 2:33pm UTC](https://discourse.julialang.org/t/how-to-stop-a-server-created-using-mux/2380/2 "2017-03-01T14:33:49Z")

</div>

From a cursory look, I don’t believe there is any way to do so. Mux puts an async closure onto the event loop and doesn’t return any references to the socket or server task. You would need to return a handle to the task, and `throwto` it to stop the server.

---

<div class="post-metadata">

**Author:** ![MikeInnes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikeinnes/32/3656_2.png) [@MikeInnes](https://discourse.julialang.org/u/MikeInnes)\
**Post date:** [March 1, 2017, 8:30pm UTC](https://discourse.julialang.org/t/how-to-stop-a-server-created-using-mux/2380/3 "2017-03-01T20:30:11Z")

</div>

Note that you may not need to, depending on your goal. `@app` is designed such that you can re-evaluate it and it will modify the server on the fly, so you shouldn’t need to kill the server to test changes.
