Address already in use error

unable to run my express code. Any port I use, I get “Address already in use” error
Repl link:

const express = require('express');
const app = express();
let indexRouter = require('./routes/indexRouter.js')

app.set("view engine", "ejs")

app.use('/', indexRouter)

const port = 3005

app.listen(port, () => {
  console.log(`server running on port ${port}`)

Hi @apoorvashirikan , welcome to the forums!
Try switching the port to another number and try again.

It seems that they already tried that:

1 Like

Hi, I tried with several port numbers. It doesn’t seem to work. For reference, this is the error I’m getting
throw er; // Unhandled ‘error’ event
Error: listen EADDRINUSE: address already in use :::5000

1 Like

Try running lsof -i tcp:5000 in the shell to see which process is using port 5000.

thanks everyone. The error was because I was already running the application on shell using (npm start) and then was trying to run again using the “Run” option. :sweat_smile: thanks again everyone for the assistance !!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.