Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to quit ASP.NET Kestrel web server on a Mac

Tags:

asp.net-core

I'm running a simple MVC app generated by Yeoman on my Mac using the ASP.NET vNext K runtime. I can run k kestrel from the project directory, and everything boots up and runs just fine. However, when I hit Ctrl+C (or any other key combination I've tried), the server doesn't quit. I have to close the terminal window to get the server to shut down. What am I missing?

like image 754
Brian Sullivan Avatar asked Sep 07 '14 17:09

Brian Sullivan


People also ask

How do you reset a Kestrel server?

Kestrel is contained in a Windows service configured to restart itself automatically upon failure. As far as i know the simplest way is to return an exit code different from 0, windows will do all the rest. Environment. Exit(1);

How do you stop a Kestrel server in Linux?

Ctrl + Break also does the trick.

What is Kestrel web server?

Kestrel is a cross-platform web server for ASP.NET Core. Kestrel is the web server that's included and enabled by default in ASP.NET Core project templates. Kestrel supports the following scenarios: HTTPS. HTTP/2 (except on macOS†)


2 Answers

If simply pressing Enter doesn't work for you, try the following in the terminal window where you're running Kestrel:

  1. Hit Ctrl + z to suspend the process.
  2. Type: kill %1.
like image 113
Andrew Avatar answered Sep 27 '22 00:09

Andrew


It turns out that simply hitting "Enter" exits kestrel cleanly, without the need to kill the mono-sgen process afterward. There is a github issue on the Kestrel repo asking to make this more obvious.

like image 23
Brian Sullivan Avatar answered Sep 26 '22 00:09

Brian Sullivan