Ad Widget

Collapse

New Setup - Remote DB Server - Connection Refused

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • brucef
    Junior Member
    • Jul 2025
    • 2

    #1

    New Setup - Remote DB Server - Connection Refused

    I am trying to deploy a new Zabbix environment and I am stuck on connecting the front-end server to the database.

    My setup:

    Zabbix Version: 7.0 LTS
    OS: Ubuntu 24.04 (Noble)
    Database: MySQL
    Web Server: Nginx

    I have built two fresh servers, both running Ubuntu, Server-1 for Server/Frontend, and Server-2 for the MySQL DB.

    I ran the following setup on Server-1
    Repo Setup
    # wget https://repo.zabbix.com/zabbix/7.0/u...u24.04_all.deb
    # dpkg -i zabbix-release_latest_7.0+ubuntu24.04_all.deb
    # apt update

    Install Zabbix
    # apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent

    Edits to zabbix_server.conf (confidential details replaced with placeholders)
    -DBHost=10.120.0.15
    -DBName=zabbix
    -DBUser=zabbix@localhost
    -DBPassword='password'
    -DBPort=3306

    Edits to nginx.conf
    -server_name 10.120.0.16;
    -listen 8080;

    Restart Services
    # systemctl restart zabbix-server zabbix-agent nginx php8.3-fpm
    # systemctl enable zabbix-server zabbix-agent nginx php8.3-fpm

    I ran the following setup on Server-2
    Repo Setup
    # wget https://repo.zabbix.com/zabbix/7.0/u...u24.04_all.deb
    # dpkg -i zabbix-release_latest_7.0+ubuntu24.04_all.deb
    # apt update

    Install Zabbix Scripts (to allow schema import)
    # apt install zabbix-sql-scripts

    DB Setup
    # mysql -uroot -p
    password
    mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
    mysql> create user zabbix@localhost identified by 'password';
    mysql> grant all privileges on zabbix.* to zabbix@localhost;
    mysql> set global log_bin_trust_function_creators = 1;
    mysql> quit;

    Schema Setup
    # zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

    When I loaded the frontend for the first time and tried to go through the initial setup I got as far as 'Configure DB connection', it fails with error 'Connection refused'.



    Things I have checked

    MySQL Status looks good

    ● mysql.service - MySQL Community Server
    Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
    Active: active (running) since Tue 2025-07-22 10:57:09 AEST; 1h 35min ago
    Process: 20028 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
    Main PID: 20037 (mysqld)
    Status: "Server is operational"
    Tasks: 38 (limit: 19098)
    Memory: 369.8M (peak: 383.6M)
    CPU: 44.261s
    CGroup: /system.slice/mysql.service
    └─20037 /usr/sbin/mysqld

    Confirmed there is a DB and Schema named 'zabbix' on the mysql server.

    It looks like the tables were correctly populated:
    +----------------------------+
    | Tables_in_zabbix |
    +----------------------------+
    | acknowledges |
    | actions |
    | alerts |
    | auditlog |
    | autoreg_host |
    | changelog |
    | conditions |
    | config |
    | config_autoreg_tls |
    | connector |
    | connector_tag |
    | corr_condition |
    | corr_condition_group |
    | corr_condition_tag |
    | corr_condition_tagpair |
    | corr_condition_tagvalue |
    | corr_operation |
    | correlation |
    | dashboard |
    | dashboard_page |
    | dashboard_user |
    | dashboard_usrgrp |
    | dbversion |
    | dchecks |
    | dhosts |
    | drules |
    | dservices |
    | escalations |
    | event_recovery |
    | event_suppress |
    | event_symptom |
    | event_tag |
    | events |
    | expressions |
    | functions |
    | globalmacro |
    | globalvars |
    | graph_discovery |
    | graph_theme |
    | graphs |
    | graphs_items |
    | group_discovery |
    | group_prototype |
    | ha_node |
    | hgset |
    | hgset_group |
    | history |
    | history_bin |
    | history_log |
    | history_str |
    | history_text |
    | history_uint |
    | host_discovery |
    | host_hgset |
    | host_inventory |
    | host_proxy |
    | host_rtdata |
    | host_tag |
    | hostmacro |
    | hosts |
    | hosts_groups |
    | hosts_templates |
    | housekeeper |
    | hstgrp |
    | httpstep |
    | httpstep_field |
    | httpstepitem |
    | httptest |
    | httptest_field |
    | httptest_tag |
    | httptestitem |
    | icon_map |
    | icon_mapping |
    | ids |
    | images |
    | interface |
    | interface_discovery |
    | interface_snmp |
    | item_condition |
    | item_discovery |
    | item_parameter |
    | item_preproc |
    | item_rtdata |
    | item_rtname |
    | item_tag |
    | items |
    | lld_macro_path |
    | lld_override |
    | lld_override_condition |
    | lld_override_opdiscover |
    | lld_override_operation |
    | lld_override_ophistory |
    | lld_override_opinventory |
    | lld_override_opperiod |
    | lld_override_opseverity |
    | lld_override_opstatus |
    | lld_override_optag |
    | lld_override_optemplate |
    | lld_override_optrends |
    | maintenance_tag |
    | maintenances |
    | maintenances_groups |
    | maintenances_hosts |
    | maintenances_windows |
    | media |
    | media_type |
    | media_type_message |
    | media_type_param |
    | mfa |
    | mfa_totp_secret |
    | module |
    | opcommand |
    | opcommand_grp |
    | opcommand_hst |
    | opconditions |
    | operations |
    | opgroup |
    | opinventory |
    | opmessage |
    | opmessage_grp |
    | opmessage_usr |
    | optag |
    | optemplate |
    | permission |
    | problem |
    | problem_tag |
    | profiles |
    | proxy |
    | proxy_autoreg_host |
    | proxy_dhistory |
    | proxy_group |
    | proxy_group_rtdata |
    | proxy_history |
    | proxy_rtdata |
    | regexps |
    | report |
    | report_param |
    | report_user |
    | report_usrgrp |
    | rights |
    | role |
    | role_rule |
    | scim_group |
    | script_param |
    | scripts |
    | service_alarms |
    | service_problem |
    | service_problem_tag |
    | service_status_rule |
    | service_tag |
    | services |
    | services_links |
    | sessions |
    | sla |
    | sla_excluded_downtime |
    | sla_schedule |
    | sla_service_tag |
    | sysmap_element_trigger |
    | sysmap_element_url |
    | sysmap_shape |
    | sysmap_url |
    | sysmap_user |
    | sysmap_usrgrp |
    | sysmaps |
    | sysmaps_element_tag |
    | sysmaps_elements |
    | sysmaps_link_triggers |
    | sysmaps_links |
    | tag_filter |
    | task |
    | task_acknowledge |
    | task_check_now |
    | task_close_problem |
    | task_data |
    | task_remote_command |
    | task_remote_command_result |
    | task_result |
    | timeperiods |
    | token |
    | trends |
    | trends_uint |
    | trigger_depends |
    | trigger_discovery |
    | trigger_queue |
    | trigger_tag |
    | triggers |
    | ugset |
    | ugset_group |
    | user_scim_group |
    | user_ugset |
    | userdirectory |
    | userdirectory_idpgroup |
    | userdirectory_ldap |
    | userdirectory_media |
    | userdirectory_saml |
    | userdirectory_usrgrp |
    | users |
    | users_groups |
    | usrgrp |
    | valuemap |
    | valuemap_mapping |
    | widget |
    | widget_field |
    +----------------------------+

    Confirmed user 'zabbix' exists in mysql.user table and that all priveldges are granted on the zabbix db
    +------------------------------------------------------------+
    | Grants for zabbix@localhost |
    +------------------------------------------------------------+
    | GRANT USAGE ON *.* TO `zabbix`@`localhost` |
    | GRANT ALL PRIVILEGES ON `zabbix`.* TO `zabbix`@`localhost` |
    +------------------------------------------------------------+

    Ran a tcpdump and confirmed the frontend server is successfully sending the login request to the correct server

    11:04:09.725550 IP 10.120.0.16.43774 > zabbix-db-01.mysql: Flags [S], seq 93411529, win 64240, options [mss 1460,sackOK,TS val 3723180798 ecr 0,nop,wscale 7], length 0
    11:04:09.725576 IP zabbix-db-01.mysql > 10.120.0.16.43774: Flags [R.], seq 0, ack 93411530, win 0, length 0
    11:04:11.282678 IP 10.120.0.16.43786 > zabbix-db-01.mysql: Flags [S], seq 1809900345, win 64240, options [mss 1460,sackOK,TS val 3723182356 ecr 0,nop,wscale 7], length 0
    11:04:11.282704 IP zabbix-db-01.mysql > 10.120.0.16.43786: Flags [R.], seq 0, ack 1809900346, win 0, length 0
    11:04:12.323994 IP 10.120.0.16.43790 > zabbix-db-01.mysql: Flags [S], seq 3948561536, win 64240, options [mss 1460,sackOK,TS val 3723183397 ecr 0,nop,wscale 7], length 0
    11:04:12.324039 IP zabbix-db-01.mysql > 10.120.0.16.43790: Flags [R.], seq 0, ack 3948561537, win 0, length 0
    11:04:14.459793 IP 10.120.0.16.40278 > zabbix-db-01.mysql: Flags [S], seq 2184583783, win 64240, options [mss 1460,sackOK,TS val 3723185533 ecr 0,nop,wscale 7], length 0
    11:04:14.459818 IP zabbix-db-01.mysql > 10.120.0.16.40278: Flags [R.], seq 0, ack 2184583784, win 0, length 0

    Checked zabbix_server.log and found the following connection error repeating

    14263:20250721:044256.902 [Z3001] connection to database 'zabbix' failed: [2003] Can't connect to MySQL server on '10.120.0.15:3306' (111)
    14263:20250721:044256.902 database is down: reconnecting in 10 seconds

    I tried enabling the mysql general logs and setting log verbosity to 2 but I'm not seeing any failed login attempts being recorded.

    I've also restarted the mysql and zabbix services multiple times.

    I'm running out of ideas here, any help would be greatly appreciated.
    ​​
  • Answer selected by Markku at 22-07-2025, 10:18.
    brucef
    Junior Member
    • Jul 2025
    • 2

    I found the fix for this.

    It was a MySQL config problem. I had not updated the bind address. By default it is set to 127.0.0.1 which only allows connections from localhost.

    You can update this by editing /etc/mysql/mysql.conf.d/mysqld.cnf and setting bind-address to the IP of the interface you want to allow connections on. Make sure to restart the mysql service afterwards.

    Comment

    • brucef
      Junior Member
      • Jul 2025
      • 2

      #2
      I found the fix for this.

      It was a MySQL config problem. I had not updated the bind address. By default it is set to 127.0.0.1 which only allows connections from localhost.

      You can update this by editing /etc/mysql/mysql.conf.d/mysqld.cnf and setting bind-address to the IP of the interface you want to allow connections on. Make sure to restart the mysql service afterwards.

      Comment

      Working...