title: Android Studio: Connection to the Internet denied error
body: <p>Whenever I try to open a project or Create a new project in Android Studio, I encounter a Gradle Project Sync error. Android Studio is displaying an error which states <strong>"Connection to The Internet Denied"</strong>. I searched the possible solutions on Stack Overflow and also the Android Developers Website, but was not successful.</p>
  
  <p>I tried all the possible solutions given in the following posts and documentation, but none of them worked for me. </p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/19678137/create-new-project-on-android-error-studio-unknown-host-services-gradle-org">Create new project on Android, Error: Studio Unknown host &#39;services.gradle.org&#39;</a></li>
  <li><a href="https://stackoverflow.com/questions/37579911/android-studio-connection-refused">Android Studio Connection Refused</a></li>
  <li><a href="https://developer.android.com/studio/troubleshoot.html" rel="nofollow noreferrer">https://developer.android.com/studio/troubleshoot.html</a></li>
  <li><a href="https://stackoverflow.com/questions/24349821/android-studio-internet-connection">Android Studio internet connection</a></li>
  </ol>
  
  <p>Here are the build.gradle and gradle.properties files:</p>
  
  <p>build.gradle - </p>
  
  <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
  
  buildscript {
  
      repositories {
          jcenter()
          google()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:3.1.1'
  
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          jcenter()
          google()
      }
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  </code></pre>
  
  <p>gradle.properties - </p>
  
  <pre><code># Project-wide Gradle settings.
  # IDE (e.g. Android Studio) users:
  # Gradle settings configured through the IDE *will override*
  # any settings specified in this file.
  # For more details on how to configure your build environment visit
  # http://www.gradle.org/docs/current/userguide/build_environment.html
  # Specifies the JVM arguments used for the daemon process.
  # The setting is particularly useful for tweaking memory settings.
  
  org.gradle.jvmargs=-Djava.net.preferIPv4Stack=true
  systemProp.https.proxyHost=localhost
  systemProp.https.proxyPort=8080
  
  # When configured, Gradle will run in incubating parallel mode.
  # This option should only be used with decoupled projects. More details, visit
  # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
  # org.gradle.parallel=true
  </code></pre>
  
  <p>When I use localhost as my ProxyHost, it throws an error saying <strong>Connection Refused: connect</strong></p>
  
  <p>Could somebody guide me in fixing this error? Thanks in Advance.</p>