阅读背景:

AWS EC2错误:无法访问该站点 - ec2.us-west-1.compute.amazonaws.com响应太晚。部署NodeJS

来源:互联网 

I currently have an EC2 instance up and running with Amazon Linux running and transferred my project (which contains both React/NodeJS/Express) onto the EC2 instance via SFTP using FileZilla.

我目前有一个运行Amazon Linux的EC2实例并运行并使用FileZilla通过SFTP将我的项目(包含React / NodeJS / Express)传输到EC2实例。

For the EC2's Security Groups, I opened a port for 3000 (protocol: tcp, source: 0.0.0.0/0), which is how my Express is defined as well.

对于EC2的安全组,我打开了一个3000端口(协议:tcp,源:0.0.0.0/0),这也是我的Express的定义方式。

So I sshed into EC2 instance and ran the project's Express, and sees it listening to port 3000 within the terminal. But once I hit the Public DNS with ec2...us-west-1.compute.amazonaws.com:3000, it says The site can't be reached - ec2...us-west-1.compute.amazonaws.com took too late to respond.

所以我进入EC2实例并运行项目的Express,并看到它在终端内监听端口3000。但是一旦我用ec2打电话给公共DNS ... us-west-1.compute.amazonaws.com:3000,它就说无法访问网站 - ec2 ... us-west-1.compute.amazonaws。 com来不及回应。

What could be the issue and how can I go about from here to connect to it?

可能是什么问题,我怎么能从这里开始连接呢?

Thank you in advance and will upvote/accept answer.

提前谢谢你,并将upvote /接受答复。

3 个解决方案

#1


1  

You may be encountering an issue with outbound traffic. You may be inside a company's network, either physically connected or VPN'd in. In some instances, your VPN isnt set up to handle split traffic, so you must abide by your company's outbound restrictions.

您可能遇到出站流量问题。您可能位于公司的网络中,无论是物理连接还是VPN输入。在某些情况下,您的VPN不会设置为处理拆分流量,因此您必须遵守公司的出站限制。

In a situation like this, you would want to use a proxy to access your site. when locking down your security group, make sure you use your proxy's public IP (not your company's).

在这种情况下,您可能希望使用代理来访问您的网站。在锁定安全组时,请确保使用代理的公共IP(不是您公司的IP)。

#2


2  

Just check if your Node.js server is running on the EC2 instance.

只需检查您的Node.js服务器是否在EC2实例上运行。

Debugging:

调试:

  1. Check first if It working locally properly.
  2. 首先检查它是否在本地正常工作。
  3. Check for the node.js server in EC2.
    • sudo netstat -tulpn | grep :3000
    • sudo netstat -tulpn | grep:3000
  4. 检查EC2中的node.js服务器。 sudo netstat -tulpn | grep:3000
  5. try to run server with --verbose flag i.e npm run server --verbose
    • it will show logs of the server while starting.
    • 它会在启动时显示服务器的日志。
  6. 尝试使用--verbose标志运行服务器,即npm运行服务器--verbose它将在启动时显示服务器的日志。
  7. Check for the security group Setting for the EC2 instance.
  8. 检查EC2实例的安全组设置。
  9. try to connect with the ip:port i.e 35.2..:3000
  10. 尝试连接ip:port,即35.2 ..:3000

If still it not working and response taking long time. that means some other service is running on the same port.

如果仍然没有工作,反应需要很长时间。这意味着其他一些服务正在同一个端口上运行。

try this in ec2:

在ec2中尝试这个:

sudo killall -9 node 
npm run server

And connect with using IP(54.4.5.*:3000) or public DNS (https://ec2...us-west-1.compute.amazonaws.com:3000).

并使用IP(54.4.5。*:3000)或公共DNS(http://ec2...us-west-1.compute.amazonaws.com:3000)进行连接。

Hope It will help :)

希望它会有所帮助:)

#3


1  

Usually, when we have connectivity issues, it is something basic or a firewall. I assume you have checked whether a firewall is running on either end, eg. iptables -L -n. Also, any protocol analyzer like wireshark or tcpdump would tell you where packets to port 3000 are visible.

通常,当我们遇到连接问题时,它是基本的或防火墙。我假设您已检查防火墙是否在两端运行,例如。 iptables -L -n。此外,任何协议分析器(如wireshark或tcpdump)都会告诉您端口3000的数据包在哪里可见。


分享到: