在 20.04 中 curl 到 localhost 失败

在 20.04 中 curl 到 localhost 失败

我有主机 20.04 和客户虚拟机盒 22.04

我尝试运行 curl 命令,但两台机器都出现了相同的错误。

运行此程序的主机:

sudo ufw status 
Status: active

To                         Action      From
--                         ------      ----
5000:5100/tcp              ALLOW       Anywhere                  
1433                       ALLOW       Anywhere                  
1434                       ALLOW       Anywhere                  
8080                       ALLOW       Anywhere                  
OpenSSH                    ALLOW       Anywhere                  
80/tcp                     ALLOW       Anywhere                  
80                         ALLOW       127.0.0.1                 
5000:5100/tcp (v6)         ALLOW       Anywhere (v6)             
1433 (v6)                  ALLOW       Anywhere (v6)             
1434 (v6)                  ALLOW       Anywhere (v6)             
8080 (v6)                  ALLOW       Anywhere (v6)             
OpenSSH (v6)               ALLOW       Anywhere (v6)             
80/tcp (v6)                ALLOW       Anywhere (v6) 

是的,有重复的规则,但我之前也遇到过同样的错误。

我尝试过将 curl 与 localhost 或 127.0.0.1 或 :80 或 :8080 组合使用,但仍然出现类似的错误

curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused
sudo netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:1434          0.0.0.0:*               LISTEN      1514/sqlservr       
tcp        0      0 127.0.0.1:1431          0.0.0.0:*               LISTEN      1514/sqlservr       
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      200812/cupsd        
tcp        0      0 127.0.0.1:33060         0.0.0.0:*               LISTEN      1169/mysqld         
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      1169/mysqld         
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      923/systemd-resolve 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1121/sshd: /usr/sbi 
tcp        0      0 0.0.0.0:1433            0.0.0.0:*               LISTEN      1514/sqlservr       
tcp6       0      0 ::1:631                 :::*                    LISTEN      200812/cupsd        
tcp6       0      0 ::1:1431                :::*                    LISTEN      1514/sqlservr       
tcp6       0      0 ::1:1434                :::*                    LISTEN      1514/sqlservr       
tcp6       0      0 :::22                   :::*                    LISTEN      1121/sshd: /usr/sbi 
tcp6       0      0 :::1433                 :::*                    LISTEN      1514/sqlservr       
udp        0      0 127.0.0.53:53           0.0.0.0:*                           923/systemd-resolve 
udp        0      0 0.0.0.0:631             0.0.0.0:*                           200814/cups-browsed 
udp        0      0 0.0.0.0:54075           0.0.0.0:*                           987/avahi-daemon: r 
udp        0      0 224.0.0.251:5353        0.0.0.0:*                           22568/chrome        
udp        0      0 224.0.0.251:5353        0.0.0.0:*                           22612/chrome --type 
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           987/avahi-daemon: r 
udp6       0      0 :::55564                :::*                                987/avahi-daemon: r 
udp6       0      0 :::5353                 :::*  

当我尝试查看端口 80 或 8080 是否正在监听时,也没有得到任何结果

sudo netstat -tnlp | grep :22
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1121/sshd: /usr/sbi 
tcp6       0      0 :::22                   :::*                    LISTEN      1121/sshd: /usr/sbi 
uss:~$ sudo netstat -tnlp | grep :80
uss:~$ sudo netstat -tnlp | grep :8080

相关内容