Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个使用 express 运行的 NodeJS 应用程序,我试图在端口 80 上访问它。
所以我有这个:
app.listen('80', function () { console.log('Server started'); });
转到浏览器,我可以通过键入“localhost”、“127.0.0.1”来访问它,无论是否使用:80 作为端口。
我的问题是如何从另一台计算机访问它?
每当我在浏览器上输入 IP 时,它都会响应“错误请求,无效主机名”
你的方法是正确的。Express 应用程序应该对同一网络上的其他计算机可见。
我最好的猜测是您的计算机上正在运行“某些东西”,阻止端口 80 暴露。或者与另一个使用端口 80 的应用程序发生冲突。(最不可能,因为如果端口已在使用中,express 将无法运行。)。