WordPressで「blocked because of many connection errors」が出た場合の対処法





Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 1384

Warning: preg_match_all(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 700

Warning: Invalid argument supplied for foreach() in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 707

Warning: preg_match_all(): Compilation failed: invalid range in character class at offset 4 in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 700

Warning: Invalid argument supplied for foreach() in /home/dotlab/webmake.info/public_html/wp-content/plugins/lightbox-plus/classes/shd.class.php on line 707




目次

背景

ある日、今まで動いていたWordPressが急に「データベースに接続できません」というエラーを吐いて止まってしまった。

当然、今まで動いていたのでユーザ名やパスワード、DBサーバ等の設定ファイルに誤りはないと考えられる。

調査の流れ

まず原因を把握する

wp-config.phpファイルの最終行にでも下記を追記してエラー内容を把握する

define('WP_DEBUG', true);
# すでに「WP_DEBUG」がfalseで定義されている場合は、その行をtrueに変更する。

その後、再度エラーが出ているページにアクセスする。

するとエラー内容が文字列で出力されているので、その内容を参考にし、エラー原因を特定する。

今回は、下記エラーが発生していた。

Warning: mysql_connect() [function.mysql-connect]: Host ’hogehoge.net’ is blocked because of many connection errors; unblock with ’mysqladmin flush-hosts’ in /wordpress-path/wp-includes/wp-db.php on line 1518

blocked because of many connection errorsとは

エラー内容のとおりであるが、何らかの原因で当該ホストからDBの接続エラーが多く発生したため、セキュリティの関係でアクセスをブロックしている。というもの。

MySQLのセキュリティ機構における機能で、通常別のホストから接続エラーが多数発生すると攻撃と判定し、その接続元をブロックするというものである。

blocked because of many connection errorsの対応

それでは、接続できるように対処していこう。

ターミナルでログイン出来る場合

エラーメッセージの指示に従い、コマンドを打てば良い。
ターミナルでエラーが出ているDBサーバにログインし、下記コマンドを実行する。

$ mysqladmin flush-hosts

phpMyAdminから実行する場合

ターミナルの利用方法がよくわからない。という場合は、phpMyAdminから下記SQLを実行することで同様のことを行うことが出来る。

FLUSH HOSTS;

どちらもDBの管理者権限でなければ実行できないため、権限があるユーザで実行しよう。
Adminユーザでの対応になるため、細心の注意を払いながら実行しましょう。

こういう時に一番怖いのは、慌てて誤ったコマンドを実行した2次災害です。

そもそも発生しない・しづらいようにする対策

発生の原因は上記の通り何らかの原因で接続エラーが多発したことにある。

接続エラーの境界値はシステム設定の「max_connect_errors」にある。

対策1:max_connect_errorsの境界値を上げる

/etc/my.cnfに通常存在するMySQLの設定ファイルから「max_connect_errors」を探し、数値が低い場合は引き上げる。

max_connect_errors = 50

デフォルト値はMySQLのバージョンによって異なり、Ver5.6.6以降は【100】。Ver5.6.5以下は【10】である。

この数値を無闇に上げることはクラッカーへそれだけチャンスを与えることになるため、出来る限り引き上げることは避けたい。

my.cnfはデーモンの起動時に反映するので、

$ service mysql reload

などを実行する必要がある。

対策2:無用なホスト接続を避ける

実は同一マシン上にWebサーバとDBサーバが存在しているのに、ホスト名で接続している。という場合、ホストを「localhost」に変更することでトラブルを回避出来る。

そんなことあるのか?と思うが、サーバをホスティングしている場合、結構存在する。

今回私が対面した状況も上記のように同一マシンでありながら、ホスティング上はその情報を開示されていないためホスト接続を行っていた。

番外編:データベースの管理権限がない場合

この対策は基本的にすべて管理者権限が必要なものです。
サーバをホスティングしている場合は、とりあえず原因の特定までを行い、エラーメッセージとともに緊急サポート窓口まで届けましょう。
それが最も早い解決策だと思います。(原因わかっても対処が出来ないため。)

こういうインシデントが発生した際に最も大切なのは「焦らないこと」です。

しっかりと順を追って対処し、ひとつずつ問題を解決し、再発しないように対策を講じていければと思います。

スポンサーリンク
スポンサーリンク




スポンサーリンク




シェアする

  • このエントリーをはてなブックマークに追加

フォローする

スポンサーリンク
スポンサーリンク