服务器上的 express 项目 运行 但无法获得任何响应

express project running on the server but could not get any response

我的快递服务器在主机上似乎没问题。但我尝试使用 IP:PORT/something 访问端点。我什么也没得到。即使我没有收到任何 500 错误。

POSTMON 说

如何修复此错误?

从您上传的图片来看,您的服务器似乎托管在 AWS EC2 上。由于您甚至无法访问您的节点服务器,看来您还没有在 EC2 安全组的入站规则中添加该端口(托管它的端口)。

您需要为所有 IP 打开该端口(如果您希望它从任何地方访问)或特定 IP,如果您只想从您的特定 IP 访问。

请详细阅读here

更新

如果您使用的是 Digital Ocean,您可以在 firewall rules.

中打开对该端口的访问

要为入站访问打开自定义 Port,您需要在防火墙中添加 custom Rules

来自官方文档

Protocol. You can choose either TCP or UDP. Because ICMP has no port abstraction, to allow ICMP traffic, you select it directly from the New rule dropdown.

Port Range. For the TCP and UDP protocols, you can specify:

  • A single port.

  • A range of ports by entering the starting and ending ports separated by a dash - with no spaces, e.g. 3000-4000. To open multiple non-sequential ports, create a separate rule for each.

  • All ports by leaving the field blank.

Sources for inbound rules, which lets you restrict the source of incoming connections.

Destinations for outbound rules, which lets you restrict the destination of outgoing connections.

You can limit the sources/destinations to:

Droplets, chosen by name, IP address, or tag DigitalOcean Load Balancers, chosen by name, IP address, or tag Non-DigitalOcean servers by IP addresses, subnets, or CIDR ranges.

请在他们的 official Documentation

中阅读有关如何在 Digital Ocean 中配置防火墙规则的信息

如果您想直接跳转到添加自定义规则,请阅读here