用 Postman 连接 Linux 服务,本质上是把 Linux 上运行的 服务/接口(HTTP、TCP、SSH 等) 作为请求目标。下面分常见场景说明。
# 查看监听端口
ss -lntp | grep 8080
# 或
netstat -lntp | grep 8080
# firewalld
firewall-cmd --add-port=8080/tcp --permanent
firewall-cmd --reload
# 或 iptables
iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
GET / POSThttp://Linux_IP:端口/接口路径
示例:
http://192.168.1.100:8080/api/test
curl:curl http://localhost:8080/api/test
直接用 IP 访问即可(如上)
设置 → 网络 → 端口转发
主机端口:8080
子系统端口:8080
Postman 访问:
http://127.0.0.1:8080
127.0.0.1ssh -N -L 8080:127.0.0.1:8080 user@linux_ip
Postman:
http://127.0.0.1:8080
Postman → Settings → Proxy
Proxy Server: socks5://127.0.0.1:1080
Postman 不支持原生 TCP
替代方案:
telnet / ncnc linux_ip 9000
Postman 不能直接连 MySQL
✅ 正确方式:
❌ 连不上原因:
127.0.0.1✅ 排查顺序:
ping linux_ipcurl localhost:portss -lntp如果你能告诉我:
我可以给你精确到命令的配置方案。