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

726
Views
localhost didn’t send any data ERR_EMPTY_RESPONSE

ERR_EMPTY_RESPONSE was working on my nodejs works but got stuck here

const http = require("https");

const server = http.createServer();
server.on("request", (req, res) => {
    var fs = require("fs");
    fs.readFile("input.txt", (err, data) => {
        if (err) return console.error(err);
        res.end(data);
    });
});

server.listen(8080, "127.0.0.1");

Ask if want more information on this. Was running it via

nodemon index.js

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Put a request listener in the createServer function like:

const http = require('http');

const requestListener = function (req, res) {
    const fs = require("fs");
    fs.readFile("input.txt", (err, data) => {
        if (err) {
            res.writeHead(500);
            res.end(`File Read Error: ${err.message}`);
        }      
        res.writeHead(200);
        res.end(data);
    });
}
const server = http.createServer(requestListener);
server.listen(8080);

about 4 years ago · Juan Pablo Isaza Report
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!