Cannot receive response upon sending http request to localhost -
something seems blocking http request localhost address. not knowledgeable regards network , windows apologize in advance if subsequent explanation not make sense somewhere.
situation: tried run simple node server programmed followed:
var express = require('express'); var app = express(); app.get('/', function (req, res) { res.set('content-type', 'text/plain'); res.send(200, 'hello http!'); }); app.listen(3000, function () { console.log("server listening!"); });
using command: node server.js, server ran , produced expected response: "server listening!"
however, when tried connect server on browser using url: localhost:3000/ received: localhost:3000/ net::err_connection_reset
this happens browsers. there no proxy in connection.
on other hand, when tried connect server external machine using url: http://x.x.x.x:3000 (x.x.x.x being computer ipv4 address), server responded "hello http!" programmed.
i have uninstalled antivirus software (360 security) , deactivated window defender (windows 8.1) result remained same. according log, windows' firewall did not block nor drop connection.
ping localhost responds normal: reply ::1: time<1ms
i have checked state of port using command: netstat -aon -b | more , shows tcp 0.0.0.0:3000 0.0.0.0:0 listening 3744 [node.exe] (proto, local address, foreign address, state, pid, ownership information)
so seems nodejs server listening on correct port.
i tested method using command: test-netconnection localhost -port 3000 , result positive.
then, tried http request test using: curl http://localhost:3000/ , result was:
curl: underlying connection closed: unexpected error occurred on receive. @ line: 1 char: 1 + curl http://localhost:3000/ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo: : invalidoperation: (system.net.httprequest:httpwebrequest) [invoke-webrequest], webexception + fullyqualifiederrorid: webcmdletwebresponseexception,microsoft.powershell.commands.invokewebrequestcommand
i tested again using advanced rest client application (chrome extension). both , post request returned no response. (status: 0, loading time: 18911 ms)
all of these tests done again using url: 127.0.0.1:3000/ result same.
i have tried fiddle hosts file (c:\windows\system32\drivers\etc\hosts) removing hash tag # before 127.0.0.1 localhost , reseting content of hosts file (copy&paste default content) nothing changed.
so know happening? not first time tried running nodejs server on computer. 1-2 months ago still doing exercises on heroku , socket.io tutorials.
Comments
Post a Comment