Skip to content
Advertisement

Cannot read property ‘writeHead’ of undefined

I have successfully hosted an local .NET server with the url: http://localhost:65349/. Now I want to change the “localhost” to my IP Address such that the Web is still running,however, the 400 HTTP error received

I have download the iisexpress-proxy into my computer by Nodejs, however, why trying to run the IIS Proxy file within my.NET project, I receive the error of “Cannot read property ‘writeHead’ of undefined” as embedded in the piece of codes below. So I want to ask what is the error and how to configure.

proxyServer.listen(proxyPort, function() {
  console.log('Listening... [press Control-C to exit]');
}).on('error', function (err, req, res) {
  console.log(err.stack);
  console.log('Listening... [press Control-C to exit]');
  res.writeHead(500, {
    'Content-Type': 'text/plain'
  });
  res.end('Aw snap! Something went wrong. Check your console to see the error.');
});

Here is the image error log:enter image description here

Advertisement

Answer

I know this is a late answer, but I got this error when I tried to use a port that was already in use as the proxy port. Using a different available port fixed it.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement