Android Studio: Gradle sync failed: Connection timed out: connect

91,072

Solution 1

I think it's a network issue. My project currently fails to build unless I pass the --offline argument to gradle. I think the S3 outage is impacting repos hosting dependencies.

Try ./gradlew tasks --offline

Or, to make android studio run in offline mode, follow the instructions: https://stackoverflow.com/a/32173577/1043518

Solution 2

I copied a project that was created else where. After removing these proxy credentials:

systemProp.http.proxyPassword=your_password

systemProp.http.proxyHost=host_Ip_address

systemProp.http.proxyUser=your_username

systemProp.http.proxyPort=port_number

in the gradle.properties, it worked like a charm.

Solution 3

For me it was the firewall. Definitely, only that. After adding Android Studio to it's whitelist everything is working like a charm.

Solution 4

Do not forget proxy for https in gradle.properties

systemProp.http.proxyHost=your.proxy.host
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=username
systemProp.http.proxyPassword=password
#
# DO NOT forget https proxy, too!
#
systemProp.https.proxyHost=your.proxy.host
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=password

Solution 5

I got the very same problem.

In my case, I started my android project on campus. Everything was fine then. When came home and started using the wifi I got the same problem (Gradle sync failed: Connection timed out).

All did is modify gradle.properties file under Gradle Scripts. I just removed the proxy settings that were stored in that file. Everything's back to normal now.

Below is an image of where to find the file:

Finding gradle.properties in your project

Share:
91,072

Related videos on Youtube

ark
Author by

ark

Updated on July 09, 2022

Comments

  • ark
    ark almost 2 years

    My Android Studio was working fine till morning, but since tonight I get error saying "Gradle sync failed: Connection timed out: connect. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.". I am not using any proxy server. Even the option for HTTP proxy is set to "no proxy". I have no idea how to get this working. I tried giving public access to Android Studio in firewall but it didn't work.

    Any help/solution is welcome.

    P.S. My Android Studio version is 2.2.3

    Thank you!

    • Prilaga
      Prilaga over 7 years
      I have the same issue, very strange
    • Naruto
      Naruto over 7 years
      I too facing same problem
    • Ayub
      Ayub almost 7 years
      before trying any solution, use a proxy or vpn.
    • Vikas Pandey
      Vikas Pandey over 5 years
      anybody has a solution, please hep me!
  • ark
    ark over 7 years
    I guess you're right, going offline fixed it. I guess some of my gradle dependencies are affected from the outage that you're talking about.
  • Anton  Malmygin
    Anton Malmygin almost 7 years
    He is not using any proxy.
  • diewland
    diewland almost 7 years
    @AntonMalmygin my mistake, sorry.
  • sɐunıɔןɐqɐp
    sɐunıɔןɐqɐp over 5 years
    From Review: Hi, this post does not seem to provide a quality answer to the question. Please either edit your answer and improve it, or just post it as a comment.
  • Adi
    Adi almost 5 years
    Same issue happened to me , Resolved just by following this method .Also make sure that No proxy is selected in to File --> Settings -->System Settings --> HTTP Proxy .
  • Marco
    Marco almost 5 years
    Thanks, had the exact same issue, seems that when i installed android studio back in 2018 it had used the proxy, forgot about it when I started working on this machine again recently.