You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker部署Zabbix栈:Web Server与Server连接失败求助

Docker Compose部署Zabbix后Web端连接Server失败的解决步骤

使用的镜像版本

docker.io/postgres:16.2
docker.io/zabbix/zabbix-server-pgsql:alpine-7.0-latest
docker.io/zabbix/zabbix-web-nginx-pgsql:alpine-7.0-latest
docker.io/zabbix/zabbix-agent2:alpine-7.0-latest

遇到的错误

Connection to Zabbix server "localhost:10051" refused. Possible reasons:

  1. Incorrect "NodeAddress" or "ListenPort" in the "zabbix_server.conf" or server IP/DNS override in the "zabbix.conf.php";
  2. Security environment (for example, SELinux) is blocking the connection;
  3. Zabbix server daemon not running;
  4. Firewall is blocking TCP connection. Connection refused

核心原因与排查解决步骤

1. 修正Web容器的Server地址配置

Docker Compose中每个容器的localhost指向自身,Web容器默认配置的localhost:10051无法访问Zabbix Server容器。直接通过环境变量修改Web容器的Server地址:
在docker-compose.yml的web服务中添加环境变量:

services:
  zabbix-web:
    # 其他原有配置...
    environment:
      - ZBX_SERVER_HOST=zabbix-server  # 此处填写你docker-compose配置中Server服务的名称

修改后重启Web容器:docker-compose up -d zabbix-web

2. 验证Server容器状态

  • 查看容器运行状态:docker-compose ps,确保zabbix-server状态为Up
  • 查看Server启动日志:docker-compose logs zabbix-server,确认没有启动失败的报错(比如数据库连接失败)

3. 检查容器网络互通性

进入Web容器测试与Server的连通性:

# 测试域名解析
docker-compose exec zabbix-web ping zabbix-server
# 测试端口连通
docker-compose exec zabbix-web nc -zv zabbix-server 10051

如果无法连通,检查docker-compose的网络配置,确保所有容器在同一网络(默认bridge或自定义网络均可)。

4. 排查宿主机安全限制

  • 防火墙:临时关闭宿主机防火墙测试:ufw disable(Debian/Ubuntu)或systemctl stop firewalld(CentOS/RHEL)
  • SELinux:临时关闭SELinux测试:setenforce 0,若问题解决,可后续配置SELinux规则允许容器间通信,或保持关闭(仅建议测试环境)

内容的提问来源于stack exchange,提问作者Andrea Montalbani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 07:08:14