简体   繁体   English

Node.js脚本加载不是从浏览器(外部)加载,而是从命令(localhost)加载

[英]Node.js script loading not loading from browser (outsider) but loading from command (localhost)

I have successfully installed Node.JS and Balloons.IO chatroom on my linux based vps (with SSH). 我已经在基于Linux的vps(使用SSH)上成功安装了Node.JS和Balloons.IO聊天室。 When typing curl http://mydomain.com:9191/ in the ssh command I can see the html is loaded. 在ssh命令中键入curl http://mydomain.com:9191/ ,我可以看到html已加载。 But, when trying to reach the same page from my browser it takes some time loading then says page could not be reached. 但是,当尝试从我的浏览器访问同一页面时,加载会花费一些时间,然后提示无法访问该页面。 Any idea why ? 知道为什么吗?

My common diagnostic steps: 我常见的诊断步骤:


1) Check that your app is actually listening on the port it should be, you can do this with: 1)检查您的应用程序实际上正在监听应该在的端口上,您可以使用以下方法执行此操作:

sudo netstat -anp | grep :9191

You should see your app listening to 0.0.0.0:9191 or your.ip.address.here:9191 if you see something like 127.0.0.1:9191 , then it is only listening locally so you won't be able to reach it. 如果看到127.0.0.1:9191 ,则应该看到您的应用程序正在监听0.0.0.0:9191your.ip.address.here:9191 ,那么该应用程序仅在本地监听,因此您无法访问它。

2) Ensure your firewall isn't blocking these ports, if you are using iptables you can check with: 2)确保您的防火墙没有阻止这些端口,如果您正在使用iptables ,则可以使用以下方法进行检查:

sudo iptables --list

This will print the rules for your firewall and you can check if you port is blocked (or allowed). 这将为您的防火墙打印规则,您可以检查端口是否被阻止(或允许)。

3) Try connecting locally. 3)尝试在本地连接。 My third step is generally to try it locally with curl , you did this step already but for other landing here you can do something like: 我的第三步通常是使用curl在本地尝试,您已经完成了此步骤,但是对于其他着陆,您可以执行以下操作:

curl http://localhost:9191/

and see what you get back 看看你得到了什么

4) Try connecting remotely. 4)尝试远程连接。 If everything above looks fine, try running a verbose curl from a remote host and see what you get: 如果上面的一切看起来都不错,请尝试从远程主机运行详细的curl,然后查看得到的结果:

curl -v http://mydomain.com:9191/

This will show header and body output so you can see if the remote host even responds; 这将显示标题和正文输出,因此您可以查看远程主机是否响应。 if it doesn't then check if the raw port is even accessable with telnet: 如果没有,则检查原始端口是否甚至可以通过telnet访问:

telnet mydomain.com 9191

which if successful will print something like: 如果成功,将打印如下内容:

Trying your.ip.address.here...
Connected to mydomain.com.
Escape character is '^]'.

If it fails it will just hang at Trying... if it fails then your firewall is blocking the port, your host is blocking the port, or your app isn't listening to the port. 如果失败,则将挂在Trying...如果失败,则说明防火墙阻止了该端口,主机阻止了该端口,或者您的应用程序未侦听该端口。 If your above tests passed then contact your host because something else may be up and you should be able to get support from them. 如果您的上述测试通过了,请与您的主机联系,因为可能有其他问题,您应该能够从他们那里获得支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM