端口无法连接
更新时间:2025-02-19 09:11:23
PDF
背景信息
访问端口失败,telnet 端口不通,服务无法连接。

操作步骤
查看云服务器服务端口是否正常启动,端口处于监听状态
以下均以常见的 80 端口为例:
通过 netstat 命令进行端口验证,如图:

未发现 80 端口处于监听状态,http 服务未启动,需先将 http 服务启动

启动完成后再次通过 netstat 进行验证

如上图标识行,80 端口处于 LISTEN 状态,表示端口处于活跃状态。
查看云服务器是否启用 iptables 或 firewall,如启用是否端口不在放行规则
虚机镜像默认是未开启 iptables 规则和 firewall 规则,部分第三方软件(如 docker,宝塔等)会自动将系统防火墙拉起来,并启用部分规则,导致部分应用端口被系统防火墙拦截。
iptables 规则查看:

firewall 规则查看

系统防火墙 iptables 和 firewall 相关服务启停命令及规则添加命令可参考:
查看安全组规则是否添加
登录云平台,选择访问云服务器所属安全组:

查看安全组下行规则是否有 80 端口的放行规则

添加 80 端口下行规则并提交

点应用修改生效
