Search code examples
amazon-ec2git-clone

Cannot clone git repo un EC2 iNSTANCE


I used the following command and tried to clone a repo but unfortunately the following error pops up. I cannot go further

ubuntu@ip-add-rr-ee-ss:~$ git clone https://github.com/repo/file.git

Cloning into 'file'... fatal: unable to access 'https://github.com/repo/file.git/': Could not resolve host: github.com


Solution

  • Could not resolve host

    This must be due to DNS issue on your EC2 instance (I can see that you're using Ubuntu here)

    1. You can try to use curl to test the connection to that URL first
    2. Check the DNS configuration: cat /etc/resolv.conf
    3. If possible, you should replace your current DNS setting with others DNS like google (8.8.8.8 & 8.8.4.4)
    4. Try to edit that file: vi /etc/resolv.conf
    5. You should insert/edit the following into:
      nameserver 8.8.8.8
      nameserver 8.8.4.4
    6. Save the file by clicking [Esc] and type :wq