ネットワークまたは Web サイトの接続の問題が発生している場合は、Hosts ファイルが問題の一部である可能性があります。 この記事では、Hosts ファイルの概要、そのしくみ、およびファイルを既定の状態にリセットすると一般的な接続の問題を解決できる理由について説明します。
Hosts ファイルの概要
Hosts ファイルは、わかりやすいホスト名 (contoso.com など) を数値のインターネット プロトコル (IP) アドレスにマッピングするためにオペレーティング システムで使用されるプレーン テキストのシステム ファイルです。 このマッピングにより、システムは IP ネットワーク上のデバイスを識別して検索することができ、オペレーティング システムの IP 実装の標準的な部分です。
Hosts ファイルの各エントリは独自の行に表示され、IP アドレスの後に空白 (タブまたはスペース) で区切られた 1 つ以上のホスト名が含まれます。 ハッシュ文字 (#) で始まる行はコメントとして扱われ、空白行は無視されます。
Hosts ファイルが既定の状態から変更されると、通常のネットワーク名前解決がオーバーライドされ、接続の問題が発生する可能性があります。 ファイルを既定の構成にリセットすると、多くの場合、Web サイトやネットワーク リソースへのアクセスに関する問題の解決に役立つ可能性があります
ホスト ファイルをリセットする
自分で Hosts ファイルを既定にリセットして戻すには、お使いのオペレーティング システムに合わせて以下の手順を実行します。
Windows 11
Windows キーを押して、「Notepad」と入力して、メモ帳アプリのアイコンを選択します。次のテキストをコピーし、ファイルに貼り付けます。
# Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost[ ファイル ] メニューの [名前を付けて保存 ] を選択し、[ ファイル名 ] ボックスに「hosts」 (引用符付き) と入力します。
[ ファイルの種類 ] を [ すべてのファイル (*.*)] に変更します。 hosts ファイルにファイル拡張子を付けることはできません。
ファイルをデスクトップに保存し、メモ帳を閉じます。
%WinDir%\System32\Drivers\Etc を検索し、[ファイル フォルダー] アイコンを選択します。
注: 通常、これはC:\Windows\System32\drivers\etc既存の Hosts ファイルを右クリックし、[ 名前の変更] を選択して、ファイル名を「Hosts.old」に変更します。
作成した Hosts ファイルをデスクトップから %WinDir%\System32\Drivers\Etc フォルダーにコピーまたは移動します。 管理者のパスワードを入力するように指示された場合、[続行] を選択します。
Windows 10 の場合
自分で Hosts ファイルを既定にリセットして戻すには、以下の手順を実行します。
Windows キーを押し、「Notepad」と入力して、メモ帳のシステム アイコンを選択します。次のテキストをコピーし、ファイルに貼り付けます。
# Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost[ ファイル ] メニューの [名前を付けて保存 ] を選択し、[ ファイル名 ] ボックスに「hosts」 (引用符付き) と入力します。
[ ファイルの種類 ] を [ すべてのファイル (*.*)] に変更します。 hosts ファイルにファイル拡張子を付けることはできません。
ファイルをデスクトップに保存し、メモ帳を閉じます。
%WinDir%\System32\Drivers\Etc を検索し、[ファイル フォルダー] アイコンを選択します。
注: 通常、これはC:\Windows\System32\drivers\etc既存の Hosts ファイルを右クリックし、[ 名前の変更] を選択して、ファイル名を「Hosts.old」に変更します。
作成した Hosts ファイルをデスクトップから %WinDir%\System32\Drivers\Etc フォルダーにコピーまたは移動します。 管理者のパスワードを入力するように指示された場合、[続行] を選択します。