by Sai gowtham

How to Fix the Error: listen EADDRINUSE in Node.js

In this tutorial, we are going to learn about how to solve the Error: listen EADDRINUSE: address already in use in Node.js.

When we run a development server of react or other apps, sometimes we will see the following error in our terminal.

Error: listen EADDRINUSE: address already in use 127.0.0.1:3000
    at Server.setupListenHandle [as _listen2] (net.js:1306:16)
    at listenInCluster (net.js:1354:12)
    at GetAddrInfoReqWrap.doListen [as callback] (net.js:1493:7)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:65:10)
Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1333:8)
    at processTicksAndRejections (internal/process/task_queues.js:81:21) {
  code: 'EADDRINUSE',
  errno: 'EADDRINUSE',
  syscall: 'listen',
  address: '127.0.0.1',
  port: 3000
}

This error tells us, the port number we are trying to run a server is already in use.

To solve this error, we need to close the program that is using this port or try to use a different port.

If you don’t know, which program is using that port then you can use the following command to kill the all node processes currently running.

killall -9 node

Top Udemy Courses

JavaScript - The Complete Guide 2020 (Beginner + Advanced)
JavaScript - The Complete Guide 2020 (Beginner + Advanced)
45,614 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
284,472 students enrolled
40 hours of video content
View Course
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
130,921 students enrolled
48.5 hours of video content
View Course