24

I am getting issue while pushing code.

git push origin master

fatal: unable to access 'https://xxxxxxxxxx@bitbucket.org/xxxxxx/xxxxxx.git/': 
Failed to connect to bitbucket.org port 443: Network is unreachable

How to avoid that error message?

AmanKumar
  • 1,333
  • 2
  • 20
  • 33
  • Can you open bitbucket in a web browser? Does the problem persist (try again an hour later or on a different computer)? – Thilo Jul 27 '16 at 07:31
  • refer [failed-to-connect-to-bitbucket-org-port-443-network-is-unreachable](https://bitbucket.org/site/master/issues/12184/failed-to-connect-to-bitbucketorg-port-443) – Rohan Khude Aug 24 '16 at 04:38
  • If the problem persists, use this style for remote URL: ```https://bitbucket.org/USERNAME/REPO.git``` – Arman Apr 08 '18 at 06:08

17 Answers17

42

TLDR; Try first git push -4 origin master


There are issues reporting current problems to access bitbucket through https (issue 13060, issue 12184)

The usual answer is:

"Failed to connect" errors could be anything from DNS issues to local network problems to ISPs that are incompletely routing Bitbucket traffic. Unfortunately, there isn't enough detail in any of these comments to diagnose the exact problems, which may or may not be related to each other. If you could, please open a support ticket with the results of the following commands:

For OS X, Linux, and other UNIX-based operating systems:

ping -c10 bitbucket.org
ping6 -c10 bitbucket.org
traceroute bitbucket.org
traceroute6 bitbucket.org
GIT_CURL_VERBOSE=1 git ls-remote https://bitbucket.org/bitbucket/do_not_delete

For Windows:

ping -n 10 bitbucket.org
ping -n 10 -6 bitbucket.org
tracert bitbucket.org
tracert -6 bitbucket.org

(To clarify: "ping6" and "traceroute6" are the IPv6 equivalents of "ping" and "traceroute", respectively, and "GIT_CURL_VERBOSE=1" before any git command will detail all the HTTP-specific parts of the connection.
On the Windows side of things, the "-6" in the command line specifies that your computer should use IPv6 for the ping or tracert.)

Additionally, if you suspect that your problem is related to Bitbucket's IPv6 support, then you should be able to test your overall IPv6 connectivity by opening the following links in your browser:

https://ipv6.google.com
https://www.v6.facebook.com

Those links should not work at all if your IPv6 connection is disabled or misconfigured.


More generally, check your /etc/hosts for any entry regarding bitbucket.org.
See "What are the Bitbucket Cloud IP addresses I should use to configure my corporate firewall?"

The IP address has recently changed:

Since July 28, 2018: IPv4 inbound for bitbucket.org, api.bitbucket.org, and altssh.bitbucket.org

18.205.93.0/25
18.234.32.128/25
13.52.5.0/25

Keep in mind ping might be blocked, triggering the same error message.


The IPV6 can be problematic: the same thread advises:

This is probably coming when git is trying to push over IPV6. I'm not exactly sure why getting this error with IPV6. But here are different solutions, that you can use to fix this problem.

Add any one of the following IP into /etc/hosts file to force git to use IPV4

104.192.143.2
104.192.143.3
104.192.143.1

That is,

104.192.143.2 bitbucket.org

To /etc/hosts file

(Or)

Upgrade your git to latest version. Probably this could solve the problem else use the following option when you push after you upgrade git (this feature was added newly to git)

 -4, --ipv4 use IPv4 addresses only

That is ,

git push -4 bitbucket dev

You can specify this option -4 while you push, pull or clone.

(Or)

You may configure git to use http proxy to solve this problem

 git config --local http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

If you are already using latest version of git, you can simply use option -4 to force git to use IPV4 address or you can go with /etc/hosts

If you wanna see debug message while pushing or pulling code you can set following environment variable before you do so,

export GIT_CURL_VERBOSE=1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I did like this but i got 2 issue : ping6 -c10 bitbucket.org - not working(no route) and /etc/hosts is read only file. i have changed the permission with sudo chmod 755/777 but its not changed. – AmanKumar Jul 29 '16 at 07:06
  • @AmanKumar If ping or tracert don't work, that is what you must solve first: firewall issue, network issue, proxy issue... – VonC Jul 29 '16 at 18:56
  • @MitraM OK: can you ask a new question with the details (version number) of your setup? – VonC Jun 11 '17 at 05:20
  • @VonC, Please see [this](https://stackoverflow.com/questions/44483533/mingwmsys2-failed-to-connect-to-bitbucket-org-port-443-network-is-unreachabl) – Maria Jun 11 '17 at 11:53
  • @Gur what version of Git are you using? – VonC Sep 25 '18 at 05:50
  • @VonC its 2.19.0 – Gurpreet Singh Sep 25 '18 at 06:12
  • @GurpreetSingh OK, I was asking, because often on an older Ubuntu, that would be a Git 2.7, and not the most recent 2.19. So, what error message do you see? – VonC Sep 25 '18 at 06:15
  • @VonC same `Failed to connect to bitbucket.org port 443: Network is unreachable` and i'm tring with all these ports `104.192.143.2 104.192.143.3 104.192.143.1` added in hosts file one by one. – Gurpreet Singh Sep 25 '18 at 06:17
  • @GurpreetSingh Can you ping it? Can you traceroute it? Can you try with bitbucket.org IP address instead of its name? (https://confluence.atlassian.com/bitbucket/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall-343343385.html) – VonC Sep 25 '18 at 06:21
  • @VonC yes but `ping6` and `traceroute6` not working. Getting `Invalid argument` with `traceroute6` and `unreacheble: no route` with `ping6`. – Gurpreet Singh Sep 25 '18 at 06:31
  • @GurpreetSingh Can you try a ping6 with the latest IPv6 for bitbucket.org, as listed in https://confluence.atlassian.com/bitbucket/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall-343343385.html (section "(Since July 28, 2018) IPv6 inbound for bitbucket.org, api.bitbucket.org, and altssh.bitbucket.org"), like 2406:da00:ff00::6b17:d1f5 – VonC Sep 25 '18 at 06:36
  • @VonC i tried `ping6 -c10 2406:da00:ff00::22cd:e0db` but getting `fe80::bac1:a2ff:fe4d:5164 icmp_seq=1 Destination unreachable: No route` – Gurpreet Singh Sep 25 '18 at 06:39
  • @GurpreetSingh I got the same on my side, even though I can do `curl -L https://bitbucket.org`. That is because my company has blocked ping (or ping6): https://superuser.com/questions/318870/why-do-companies-block-ping – VonC Sep 25 '18 at 06:43
  • @GurpreetSingh I have edited the answer accordingly, which should allow you to cancel your downvote. – VonC Sep 25 '18 at 13:02
30

I followed the discussion on this page and added this line to my hosts file:

104.192.143.2 bitbucket.org

It works . My system is unbuntu, so the host file is in /etc/hosts and you need have root permission.

Neuron
  • 5,141
  • 5
  • 38
  • 59
monjer
  • 2,809
  • 2
  • 21
  • 31
13

this is crazy ,after removing 104.192.143.2 bitbucket.org from /etc/hosts it started working for me

ganesh
  • 2,024
  • 16
  • 17
5

Just add an entry to your ~/.ssh/config as follows:

Host bitbucket.org
  AddressFamily inet
aronbo
  • 303
  • 4
  • 9
  • This is actually a helpful answer, differing from the other ones, not every solution here will work for every person, so I see no reason why this should have been avoided – Brian Deragon May 24 '17 at 15:07
  • It would be great if this solution could be incorporated in the accepted answer. This is a better solution than hard-coding an ip address that could well change in the future. – FoxyLad Sep 10 '18 at 00:51
4

I got this resolved. One of the reasons it happens is due to your system being on proxy network. In that case you have to run below command :

$ git config --global http.proxy http://username:password@proxy:port

where, username : your system userID| password : system password | proxy : Ip address of the proxy you are using | port : Of that proxy|

This was hapenning due to network limitation of my organization network.

Nikhil Kumar
  • 88
  • 11
4

I have removed 104.192.143.2 bitbucket.org from this path /etc/hosts. It start working.

Edit: I again faced error of Failed to connect to bitbucket.org port 443: Network is unreachable.

I added new ip 18.205.93.0 bitbucket.org and it is working perfectly. You can find ip simply typing this command ping -c10 bitbucket.org.

Referance: For more information visit this link

badarshahzad
  • 1,227
  • 16
  • 25
3

switch the network provider. Some times your network provider causes this kind of issue.

2

Check firewall settings. This was the issue in my case.

KalenGi
  • 1,766
  • 4
  • 25
  • 40
2

Suggestion 1: Just remove your origin and set the origin again, then try to push/pull. Hopefully, it will work.

 git remote -v
 git remote remove origin
 git remote add origin https://habibus@bitbucket.org/softbd/oss-project.git 

Suggestion 2: Remove those of lines from Windows/System32/drivers/etc/hosts if any one of these lines is available.

 104.192.143.1 bitbucket.org
 104.192.143.2 bitbucket.org
 18.205.93.0 bitbucket.org

Suggestion 3: Change the network connection/provider. Sometimes your network provider causes this kind of issue.

Suggestion 4: Check firewall settings. Sometimes it was the issue for showing this kind of error.

Suggestion 5: Check your git version and then run the following command to upgrade.

 sudo add-apt-repository ppa:git-core/ppa
 sudo apt-get update
 sudo apt-get install git
daud
  • 33
  • 5
Majbah Habib
  • 8,058
  • 3
  • 36
  • 38
0

If you are still getting this error and the above doesn't work, it may be a firewall issue; meaning something is blocking the connection deliberately, rather than a "failure". Try double-checking your Firewall, and follow your standard steps for Network Troubleshooting.

From the basic google searching I did, the three main reasons for this error is invalid proxy settings, mishandling IPv6 Addresses, or general network error on client-side.

0

Flushing dns cache worked for me (Ubuntu, 18.04):

sudo systemd-resolve --flush-caches

Be Kind
  • 4,712
  • 1
  • 38
  • 45
0

we can solve by setting proxy in command prompt before push commits to the repo.

set HTTP_PROXY=http://user:pass@your_proxy: port
Aravind S
  • 2,347
  • 2
  • 12
  • 21
shankar gupta
  • 1,059
  • 7
  • 3
0

just add your proxy setting via command prompt :

set HTTPS_PROXY=http://user:pass@yourProxy:8080

shankar gupta
  • 1,059
  • 7
  • 3
0

so i was having the same problem where neither i was able to load bitbucket in browser or push pull clone bitbucket from terminal i followed discussion. where in my hosts file had 104.192.143.3 bitbucket.orgwhich was added when i used bit bucket for first time for another project .

so thought of removing it from hosts file , it started working again its bit strange community has to come up with the reason for this

Manoj Rammoorthy
  • 1,384
  • 16
  • 16
0

I got that problem and even change /etc/hosts with IP address from official IP addresses https://confluence.atlassian.com/bitbucket/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall-343343385.html

Server not clone any project from bitbucket through use ip4 like that 104.192.143.1 and just slow and no response

For me SOLVED enable/add ip6 in /etc/network/interfaces . LOL, For every virtualization individual, but for kvm is looks like

iface ens3 inet6 static
        address 2a04:5200:fff5::89e
        netmask 48
        gateway 2a04:5200:fff5::1
        up ip -6 addr add 2a04:5200:fff5::8ea dev ens3
        down ip -6 addr del 2a04:5200:fff5::8ea dev ens3

For OpenVZ looks like

iface venet0 inet6 manual
    up ifconfig venet0 add 2a04:5200:fff7::bb6/128
    down ifconfig venet0 del 2a04:5200:fff7::bb6/128
    up route -A inet6 add default dev venet0
    down route -A inet6 del default dev venet0

Try active or add ip6 ip adress in your panel hosting and reinstall it, but delete all files there.

Eugene
  • 1
0

This worked for me. I ran this below command

ping -n 10 bitbucket.org

And then sync from visual studio Team explorer. Then it worked

Abdus Salam Azad
  • 5,087
  • 46
  • 35
0

For windows open your command prompt and do:

  1. ping -n 10 bitbucket.org
  2. tracert bitbucket.org

This will definitely gone a solve it. It works on mine.

Nabin Rawat
  • 347
  • 4
  • 8