Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

508
Visualizações
How to fix node.js error when trying to execute?

I am starting to work with server side (node.js), and am having some errors when I try to execute it. I am using 127.0.0.1:80 as the server, but I am experiencing some errors when I try to run it.

Console:

Server running at http://127.0.0.1:80/
node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: Listen EACCES: permission denied 127.0.0.1:80
  //at Server.setupListenHandle [as _listen2] (node:net:1363:21)
  at listenInCluster (node:net:1428:12)
  at doListen (node:net:1567:7)
  at processTicksAndRejections (node:internal/process/task_queues:83:21)//
Emitted 'error' event on Server instance at:
  at emitErrorNT (node:net:1407:8)
  at processTicksAndRejections (node:internal/process/task_queues:83:21) {
       code: 'EACCES',
       errno: -13,
       syscall: 'listen',
       address: '127.0.0.1',
       port: 80
 }

Javascript:

 var http = require('http');
 http.createServer(function (req, res) {
   res.writeHead(200, {'Content-Type': 'text/plain'});
   res.end('Hello World\n');
 }).listen(80, '127.0.0.1');
 console.log('Server running at http://127.0.0.1:80/');

package.json:

     {
   "name": "test-web-server",
   "version": "1.0.0",
   "description": "Node.js test server. Use for whatever bs you want to do",
   "main": "index.js",
   "scripts": {
     "start": "node server.js",
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   "author": "PlazL",
   "license": "ISC"
 }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

a rule of thumb is that listening to ports less than 1024 often requires elevated privileges. Try changing the port to 8080, or elevate your privileges with sudo.

For brevity here is the change in your code:

 var http = require('http');
 http.createServer(function (req, res) {
   res.writeHead(200, {'Content-Type': 'text/plain'});
   res.end('Hello World\n');
 }).listen(8080, '127.0.0.1'); // change port here (80 -> 8080)
 console.log('Server running at http://127.0.0.1:80/');
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda