Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

412
Views
having issue connecting my mongodb to my nodejs app

//in my .env file

MOVIEREVIEWS_DB_URI=mongodb+srv://driiisdev:password123@cluster1.ektx7.mongodb.net/sample_mflix?retryWrites=true&w=majority

PORT=8000 //starting port of server

//in my index.js file

import app from "./server.js"
import mongodb from "mongodb"
import dotenv from "dotenv"

dotenv.config(); 

const uri = process.env.MOVIEREVIEWS_DB_URI;

const client = new mongodb.MongoClient(uri);

const port = process.env.PORT||5000;


(async ()=>{

try{
    //Connect to the MongoDB cluster
    await client.connect();
    app.listen(port, ()=>{
        console.log("server is running on port:" +port);
    })
}catch(e){
    console.error(e);
    process.exit(1)
    }
})().catch(console.error);

//in my server.js file

import express from 'express'
import cors from 'cors'
import movies from './api/movies.route.js'

const app = express()
app.use(cors())
app.use(express.json())
app.use("/api/v1/movies", movies)

app.use('*', (req,res)=>{
    res.status(404).json({error:"not found"})
})

export default app

// on running nodemon server , the error i get:

Error: listen EACCES: permission denied 8000 //starting port of server
at Server.setupListenHandle [as _listen2] (node:net:1317:21)
at listenInCluster (node:net:1382:12)
at Server.listen (node:net:1480:5)
at Function.listen (C:\xampp\htdocs\driiisdev\movie-reviews\backend\node_modules\express\lib\application.js:635:24)
at main (file:///C:/xampp/htdocs/driiisdev/movie-reviews/backend/index.js:19:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Emitted 'error' event on Server instance at: at emitErrorNT (node:net:1361:8) at processTicksAndRejections (node:internal/process/task_queues:83:21) { code: 'EACCES', errno: -4092, syscall: 'listen', address: '8000 //starting port of server', port: -1 }

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!