Intermittent Connection refused and MySQL server has gone away with MariaDB on Debian 11 (Oracle VM) [closed]

Intermittent SQLSTATE[HY000] [2002] Connection refused and SQLSTATE[HY000]: General error: 2006 MySQL server has gone away with MariaDB on Debian 11 (Oracle VM)

Question:

I’ve been experiencing frequent issues with my MariaDB setup on Debian 11, which is running on Oracle VM. The errors I’m seeing alternate between:

  • SQLSTATE[HY000] [2002] Connection refused
  • SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

Setup Details:

  • MariaDB version: 11.5.2-MariaDB, client 15.2 for debian-linux-gnu (x86_64)
  • OS: Debian 11 (on Oracle VM)
  • PHP version: PHP8.3
  • The database is accessed via both mysqli and PDO.
  • The MariaDB server is running locally, accessed via both TCP and UNIX socket.
  • Remote access with HeidiSQL works fine.

Steps I’ve Tried:

  1. Adjusted settings like max_allowed_packet, wait_timeout, interactive_timeout, innodb_buffer_pool_size, and connect_timeout — but the problem persists.
  2. Verified that MariaDB is running correctly using systemctl status mariadb.
  3. Tested the connection manually via both socket and TCP:
    • mysql -u root -p (local UNIX socket)
    • mysql -h 127.0.0.1 -P 3306 -u root -p (TCP)
      Both methods work manually, but the errors still appear in the application.
  4. Checked firewall settings and confirmed that port 3306 is open.
  5. Reviewed /var/log/mysql/error.log for errors, but found nothing directly explaining the issue.
  6. PHP connection pooling (persistent connections) is in use via PDO::ATTR_PERSISTENT, but the issue remains.

Observations:

  • The “Connection refused” error occurs sporadically.
  • The “MySQL server has gone away” error seems more frequent after long-running or large queries.
  • System resources seem sufficient (htop shows moderate to zero CPU and memory usage).
  • This setup works fine on XAMPP (Windows), but not on Debian 11 with Oracle VM.

Questions:

  • What could cause these intermittent connection issues, especially with the alternating errors?
  • Could this be related to how MariaDB handles connections on Debian 11 (Oracle VM) vs XAMPP on Windows (which works fine)?
  • Are there any specific MariaDB, Oracle VM, or network settings I might have missed that could stabilize the connection?

4

I was able to solve the issue by switching to Debian 12 and PHP 8.2. It seems the problem was related to using Debian 11 and PHP 8.3, although I’m not entirely sure whether the root cause was Debian 11, PHP 8.3, or the interaction between the two.

After making the switch, everything works as expected:

  • MariaDB no longer causes connection issues.
  • Both local Symfony connections and remote connections via HeidiSQL are stable and perform as expected.

Addendum:

I’ve finally identified the root cause of the issue. The problem was related to the use of the MariaDB setup script from mariadb.com:

curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash

Even though this is an official script, it seems to have caused instability in my environment. When I removed that line and installed MariaDB directly from the official Debian repositories, everything worked perfectly, and MariaDB has been stable ever since.

The issue had nothing to do with PHP (as I initially thought), because I experienced connection problems even when using a remote client like HeidiSQL.

So, if you’re running into similar issues, I recommend avoiding the setup script from mariadb.com and sticking with the packages provided in the Debian repos. This solved all the connection problems for me.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật