![](/img/trans.png)
[英]node.js/sqlite3 SELECT works from command line but not from JS binding
[英]node.js script works off command line but not from browser?
我启动了运行ubuntu 12.04的amazon ec2实例
然后我按照说明从http://howtonode.org/how-to-install-nodejs安装node.js
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
然后我使用示例代码来创建hello.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.js\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');
然后我跑了hello.js
/var/www$ node hello.js
Server running at http://127.0.0.1:8124/
但是,当我尝试从URL访问此内容时,使用http://ec2-***.compute-1.amazonaws.com:8124/
我从浏览器中收到错误页面。
关于如何让它出现在浏览器中的任何建议?
编辑我在更改上面的代码行后仍然遇到这个问题
}).listen(8124, "127.0.0.1");
对此
}).listen(8124);
127.0.0.1是环回地址。 只有主持人才能访问它。 如果要侦听任何可用的IP,请不要指定该参数。 否则,请指定要侦听的真实IP。
我也有同样的问题,卸载skype为我工作,你也可以搜索一些强制skype移动到其他端口的设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.