Skip to content

Instantly share code, notes, and snippets.

@YenHub
Last active March 10, 2021 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YenHub/c2e79563c79db560ab9e4c8472289520 to your computer and use it in GitHub Desktop.
Save YenHub/c2e79563c79db560ab9e4c8472289520 to your computer and use it in GitHub Desktop.
Temp Fix: DNS Issues, cannot access 'https://some-url.com'

Temporarily Resolve Local DNS Issues

This snippet describes a workaround which can help when you're having issues connecting to a particular resource.

This is of course a temporary work around, however, can certainly get you out of a muddle fast!

For example, if you're unable to get to the nuget host, this guide can help you resolve this (temporarily!)

You can confirm whether you're having DNS issues, if for example, other connectivity otherwise appears fine, and a particular URL or resource will not resolve.

ping nuget.someneatresource.com

Ping request could not find host nuget.someneatresource.com. Please check the name and try again.

General recommendations

  • Turn it off and on again.... Both your system & router can always benefit from a restart
  • Before touching your hosts file, try the following from your command prompt:-
# Release your IP Address
ipconfig /release

# Renew the IP Address
ipconfig /renew

# Flush your DNS Cache
ipconfig /flushdns

Afterword

The steps in this snippet will of course help you to get to the resource, however, this is not a permanent fix and it would be sensible to investigate the issue further in case things worsen!

Example

This snippet uses the example of being unable to access nuget.someneatresource.com

Ask a friend to check the IP address for the resource from a working system (particularly if it's behind a VPN)

ping nuget.someneatresource.com

# Pinging nuget.someneatresource.com [10.1.3.95] with 32 bytes of data:
# Reply from 10.1.3.95: bytes=32 time=23ms TTL=254
# Reply from 10.1.3.95: bytes=32 time=24ms TTL=254

From the above, we can see the resource is hosted on IP Address 10.1.3.95

Instructions to edit your hosts file

  1. Open an elevated command prompt
  • WIN + R
  • Type 'notepad'
  • Use CTRL + SHIFT + ENTER to launch notepad as an administrator
  1. Open your hosts file
  • File >> Open >> Navigate to: C:\Windows\System32\drivers\etc
  • Change 'File Type' to 'All Files'
  • Double click 'hosts' to edit the file
  1. Add the following line at the footer of your hosts file:-
10.1.3.95   nuget.someneatresource.com
  1. Save the file & clear your DNS Cache
  • ipconfig /flushdns
  1. Test the change has been a success by pinging the IP Address, you should now see responses from the resource
  • ping nuget.someneatresource.com

NOTE: Some windows systems prefer a tab between the IP address and the hostname!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment