[英]Connection refused with a basic HTTP server on AWS EC2
我知道有很多關於這個主題的資源,但我認為我做的一切都正確,但我仍然無法連接到我的服務器。
我在端口 80 上啟動了一個簡單的 node.js 服務器。
sudo netstat -tnlp | grep 80
tcp 0 0 127.0.0.1:80 0.0.0.0:* LISTEN 3657/node
curl localhost:80
Welcome Node.js
我確保沒有本地防火牆並且 VPC ACL 沒有阻塞流量(不是我所期望的,因為這是一個全新的實例。)
service iptables status
Redirecting to /bin/systemctl status iptables.service
Unit iptables.service could not be found.
當我嘗試從本地計算機連接時,output:
curl 3.xxx.xxx.xxx
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:03 --:--:-- 0
curl: (7) Failed to connect to 3.xxx.xxx.xxx port 80: Connection refused
關於接下來要檢查的內容還有其他想法嗎?
我的問題的答案是https://stackoverflow.com/a/14045163/2369000 。 我復制的樣板代碼使用了一種僅偵聽來自 localhost 的請求的方法。 這可能是從 netstat output 中檢測到的,它表示監聽地址為127.0.0.1:80
。 答案是使用.listen(80, "0.0.0.0")
或僅.listen(80)
因為默認行為是偵聽來自任何 IP 地址的請求。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.