Answer the question
In order to leave comments, you need to log in
How to kill Go server process on Linux Centos?
I'm learning Go. In the first file, port listening is written:
As a result, a test web page is displayed at this address. Everything is great!
But now I need to stop this process and edit the content of the app. How to do this is not clear. The fact is that there are a lot of instructions on how to start the server, but how to stop it is not clear.
top and System Monitor does not help to find the right process to kill it.
How to stop listening to this very port?
Just in case, I’ll clarify the following: I
start the server: go run server.go - after which you can’t do anything else in the console - it seems to stickhttp.ListenAndServe("localhost:8181", msgHandler)
I press CTRL + Z - and again I can work in the console, but at the end of the day nothing is displayed at localhost: 8181, and the browser just hangs endlessly. Whereas accessing the undefined port localhost: 8282 - quickly fulfills and writes "The connection attempt failed" The
issue is resolved! Thanks to those who responded!
I must say that both options work, and I just marked the first answer as a solution, especially since it is more detailed.
* Important note
From myself, I note that these commands will not work if you press CTRL + Z. You must first kill the process in another console window, then actually pressing CTRL + Z is not necessary. Something similar happens with the geany program (which I run as root to edit configs): if you don’t complete it with a cross, then CTRL + Z will return control to the console, but then you suffer to close geany itself. Here is the same garbage: if you press CTRL + Z, then no process will be found and will not be killed
* Note 2
It turns out that you need to press CTRL + C, but I always pressed the wrong ...
Answer the question
In order to leave comments, you need to log in
You need to find the process that is listening on this port and kill it.
Since the name of the program is known, then just like this:pkill myprog
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question