Intermittent EADDRINUSE :::5000

151 views Asked by At

So, sometimes when I reboot my server it fixes it and sometimes it doesn't but I continuously get Error: listen EADDRINUSE :::5000. In my package.json in my client I have a proxy for "proxy": "http://localhost:5000" and I changed that to port 3000 to test it, still issue persisted. I went into server.js and tried just changing the port but any port I change it to it says it's in use. So, it has to be an issue with how I am setting up express i'm assuming. I just don't know what to even change since it's intermittent.

Also it's weird my server is still running because my socket works...

edit Here are my scripts:

"scripts": {
    "client-install": "npm install --prefix client",
    "start": "node server.js",
    "server": "nodemon server.js",
    "client": "npm start --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\"",
  },

server.js snippet

const express = require("express");
const app = express();
const port = process.env.PORT || 5000;
var server = app.listen(port, () =>
  console.log(`Server running on port ${port}`)
);
var io = (module.exports.io = require("socket.io").listen(server));
1

There are 1 answers

0
Snoopy On

I ended up just using killall node if I ran into this issue