-1

I tried a basic beginner program in Node.Js where I wanted to use the built-in module 'http'. After executing a basic program of http.createServer(). Below is my source code.

var http = require('http');


http.createServer(function (req, res) {
  res.write('Hello World!'); 
  res.end(); 
}).listen(8080);

When running the code in cmd it didn't run and displayed the following error.

events.js:287
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::8080
    at Server.setupListenHandle [as _listen2] (net.js:1313:16)
    at listenInCluster (net.js:1361:12)
    at Server.listen (net.js:1449:7)
    at Object.<anonymous> (F:\NodeJS\first app\w3schools\moduleIntro,.js:7:4)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47
Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1340:8)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 'EADDRINUSE',
  errno: 'EADDRINUSE',
  syscall: 'listen',
  address: '::',
  port: 8080
}
Thiluxan
  • 177
  • 4
  • 13

1 Answers1

1

Ok, it's not problem in your code actually 8080 already running anywhere else so you can't run the same port number at a time so just close all running process Or you just shut down your PC and run again the problem will be resolve.

saurabh Singh
  • 4,902
  • 3
  • 11
  • 12