'Error: listen EACCES: permission denied 8085;

I tried running the backend server but when I run the command node backend/server.js in my cmd, I'm getting this error:

D:\theshoppingcart>node backend/server.js
events.js:187
      throw er; // Unhandled 'error' event
      ^

Error: listen EACCES: permission denied 8085;
    at Server.setupListenHandle [as _listen2] (net.js:1284:19)
    at listenInCluster (net.js:1349:12)
    at Server.listen (net.js:1448:5)
    at Object.<anonymous> (D:\theshoppingcart\backend\server.js:16:8)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
    at internal/main/run_main_module.js:17:11
Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1328:8)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  code: 'EACCES',
  errno: 'EACCES',
  syscall: 'listen',
  address: '8085;',
  port: -1
}

this is my backend/server.js file:

require('dotenv').config()
const express = require("express");
const connectDB = require('./config/db');

connectDB();

const app = express();

const PORT = process.env.PORT || 8085;

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


Solution 1:[1]

I had the same issue, you should remove the semicolon ; from the .env file. That has worked for me.

Solution 2:[2]

Open the .env file and check ";".

PORT = 5050;

You need to remove the ";" from the .env file. make it:

PORT = 5050

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fernando
Solution 2 Tyler2P