0
0

Ubuntu: `sudo: unable to resolve host ip-xxx-xxx-xxx-xxxのエラー修正

Posted at

Ubuntu: `sudo: unable to resolve host ip-xxx-xxx-xxx-xxxのエラー修正

  • 今回はホスト名に関する変なエラーが出たので解決しました。AWSさんが勝手にホスト名を書いてくれるせいだと思います。

エラーの修正方法

このエラーは通常、/etc/hostname/etc/hosts ファイルの間でホスト名の不一致が生じている場合に発生します。

手順1: /etc/hostname ファイルを確認

まず、/etc/hostname ファイルに現在設定されているホスト名を確認します。

cat /etc/hostname

このコマンドが ip-xxx-xxx-xxx-xxx または他のホスト名を出力するはずです。

手順2: /etc/hosts ファイルを修正

次に、/etc/hosts ファイルをエディタで開きます。

sudo vi /etc/hosts

ファイルを開いたら、以下のような行が存在するはずです。

127.0.0.1 localhost

この行の下に、以下のように新しい行を追加します。ここで ip-xxx-xxx-xxx-xxxは /etc/hostname ファイルで確認したホスト名に置き換えてください。

127.0.0.1 ip-xxx-xxx-xxx-xxx

変更を保存してファイルを閉じます。

手順3: システムのホスト名を更新

以下のコマンドでシステムのホスト名を即座に更新します。

sudo hostname -F /etc/hostname

手順4: システムの再起動

最後に、設定を確実に反映させるためにシステムを再起動します。

sudo reboot
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0