我有一个不运行我的Ubuntu虚拟机的Node.js Express服务器,该虚拟机在Windows笔记本电脑中运行。我正在尝试向另一个nodejs应用程序发出请求,同样也是在同一虚拟机中运行的时候。
我遇到一个错误,说Your requested host 'localhost' could not be resolved
在Google上搜索了一些内容并尝试了无法使用的DNS设置后,我在呼叫快递应用上将localhost
替换为127.0.0.1
。
现在这不会因错误而失败,而是通过指向Microsoft iis服务器页面的链接进行响应。
我不确定该如何解决? 更改DNS唯一的方法吗?
编辑:
nodejs应用程序正在运行3000(提供一些json),已通过浏览器进行了验证。
但是通过curl
,我得到了重定向响应:
<HTML>
<HEAD><TITLE>Redirection</TITLE></HEAD>
<BODY><H1>Redirect</H1></BODY>
在节点REPL中,我得到一个Microsoft IIS页面作为响应:
request('http://127.0.0.1:3000/abc', function(error, response, body) { console.log(response);});
body: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r\n' +
'<html xmlns="http://www.w3.org/1999/xhtml">\r\n' +
'<head>\r\n' +
'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />\r\n' +
'<title>IIS Windows</title>\r\n' +
'<style type="text/css">\r\n' +
'<!--\r\n' +
'body {\r\n' +
'\tcolor:#000000;\r\n' +
'\tbackground-color:#0072C6;\r\n' +
'\tmargin:0;\r\n' +
'}\r\n' +
'\r\n' +
'#container {\r\n' +
'\tmargin-left:auto;\r\n' +
'\tmargin-right:auto;\r\n' +
'\ttext-align:center;\r\n' +
'\t}\r\n' +
'\r\n' +
'a img {\r\n' +
'\tborder:none;\r\n' +
'}\r\n' +
'\r\n' +
'-->\r\n' +
'</style>\r\n' +
'</head>\r\n' +
'<body>\r\n' +
'<div id="container">\r\n' +
'<a href="http://go.microsoft.com/fwlink/?linkid=66138&clcid=0x409"><img src="iisstart.png" alt="IIS" width="960" height="600" /></a>\r\n' +
'</div>\r\n' +
'</body>\r\n' +
'</html>'