Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
6

How can I stop nodejs?

cptneko
cptneko

Hello. I have started an express+socketio server with the standard:

var app = express(); var server = http.Server(app); server.listen(3000, () => console.log('listening on *:3000'));

code, but I cannot seem to be able to restart it since I have closed it and reopened. I get

Process crashed with: Error: listen EADDRINUSE: address already in use :::3000 at Server.setupListenHandle [as _listen2] (net.js:1279:14) at listenInCluster (net.js:1327:12) at Server.listen (net.js:1414:7) at evalmachine.<anonymous>:17:8 at Script.runInContext (vm.js:133:20) at Object.runInContext (vm.js:311:6) at evaluate (/run_dir/repl.js:133:14) at ReadStream.<anonymous> (/run_dir/repl.js:116:5) at ReadStream.emit (events.js:198:13) at addChunk (_stream_readable.js:288:12)

If I change the port then it stars but my client is unable to connect as the old version gets connected. So how could I stop the already running version and start the new one?

3 years ago

Voters

Comments

TopNew
3
chicagokiwi
chicagokiwi

Press F1 in the Editor then type and/or select Open Shell.

Within the shell, execute the following:
find /proc -mindepth 2 -maxdepth 2 -name exe -exec ls -lh {} \; 2>/dev/null

You can then:
kill -9 [pid]

3 years ago
2
vedprad1
vedprad1

After you change the port number, you just have to wait for a while, and then you can go back to the original port.

However, I would recommend that you do not even press the start / restart button unless you are making a change to the server. If you are just changing an express route, a socket.io connection, or you change client side, you don't have to restart server. Instead, you should just make a new client, and it should be updated.

3 years ago
1
rshetty
rshetty

If changing the port isn’t working, press ctrl-shift-P to open the little repl menu, then select open shell. You now get access to the Linux file system and command line. You will then be able to use any non-superuser method to stop the server.

3 years ago
5
cptneko
cptneko

@rshetty
How can I kill it there? kill takes a pid and there is only killall5 which I have never seen and sadly ps isn't available :(

3 years ago
2
kevinisyoung
kevinisyoung

@cptneko
Did you figure this out?

3 years ago
1
SpaceSaver2000
SpaceSaver2000

@cptneko
If you're still having this problem, try killall5 -9 and then kill 1

5 months ago
1
mwilki7
mwilki7

Maybe you've done this already but try refreshing the page.
That error has happened to me before. I don't remember how I solved it, though.

3 years ago
Load more