I am using a virtual IDE called codesandbox not any offline code editors

dependencies installed

  1. npm globally
  2. nodemon
  3. express
  4. supervillains

here's the error

$ nodemon index.js
[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index.js`
[nodemon] clean exit - waiting for changes before restart
^Csandbox@sse-sandbox-mr85r2:/sandbox/server$ node iex.js
sandbox@sse-sandbox-mr85r2:/sandbox/server$ nodemonindex.js
[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index.js`
[nodemon] clean exit - waiting for changes before restart
[nodemon] restarting due to changes...
[nodemon] starting `node index.js`
events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: listen EACCES: permission denied 0.0.0.0:1000
    at Server.setupListenHandle [as _listen2] (net.js:1314:21)
    at listenInCluster (net.js:1379:12)
    at Server.listen (net.js:1465:7)
    at Function.listen (/sandbox/server/node_modules/express/lib/application.js:635:24)
    at Object.<anonymous> (/sandbox/server/index.js:9:5)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1358:8)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  code: 'EACCES',
  errno: -13,
  syscall: 'listen',
  address: '0.0.0.0',
  port: 1000
}
[nodemon] app crashed - waiting for file changes before starting...

code in my index.js

const express = require("express");

const app = express();

app.get("/", (req, res) =>
  res.send(console.log("Hello world the server is now running"))
);

app.listen(1000, () =>
  console.log("The server is running on port 8000 successfully")
);

tried :

  • installed npm install -g kill-port*
  • also tried to execute npm kill port command but it showed that it has killed it but when i checked it was still listening*

expected: the listening port should be killed but it didn't got killed. after executing the command npx kill port 8080

resulted: after running the index.js file got this error

code: 'EACCES',
  errno: -13,
  syscall: 'listen',
  address: '0.0.0.0',
  port: 1000
1

There are 1 best solutions below

0
user19258675 On

Simple, your NodeJS server is listening on port 1000, but you are trying to kill port 8080. use

npx kill port 1000