I am trying to learn some features of node on ubuntu and after I press ctrl+z on my console to stop the server I had (in order to restart server for recognizing my changes on the code), the node still listens to the port (in this case 3000 ).
Then, everytime I have to find the pid by typing
lsof -i tcp:3000
and kill it manually by typing
sudo kill -9 pid_number_I_got
I just wonder why it still listens to it and I want not to have to do this thing everytime. Any help ?
The code
var http = require("http");
var server = http.createServer(function(req,res){
console.log(req.url , req.method);
res.end("hello \n");
});
server.listen(3000);
The answer is correct. Type ctrl+c , it works. I was typing ctrl+x instead.
Ctrl+Z moves a running application to the background; you can run the fg
command to resume it. To stop the server, you should use Ctrl+C.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With