bitbucket can't pull/push from repository
Asked Answered
T

27

45

So basically I have a server where I have bitbucket git repository set up. I've been using it for months and now out of the blue sky when I try to pull I get the following error:

ssh: Could not resolve hostname bitbucket.org: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I'm 100% sure I have correctly setup my ssh-keys.

git remote -v
origin  [email protected]:marel/tshirtmafia.git (fetch)
origin  [email protected]:marel/tshirtmafia.git (push)

Any suggestions how to fix this ? Please let me know if you need anything else.

Townspeople answered 20/4, 2015 at 12:31 Comment(2)
"Could not resolve hostname bitbucket.org". Sounds like a problem with your DNS. Could be transient.Agnusago
@Agnusago I noticed this more than 24 hours ago..Townspeople
O
37

This issue is caused by incorrect git configuration. Open .git folder in root folder of your project and in config file please find the line that starts with

url = [email protected]

Most probably you have specified protocol there and defined url like url = ssh://[email protected]

remove ssh:// and it should do the trick for you.

Outrun answered 14/1, 2016 at 13:1 Comment(5)
I try this and not work, I have this error: ` $ git push fatal: '[email protected]/myusername/my_project.git' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.`Encephalic
this worked for me, but does that mean that it isn't secured with SSH anymore after removing that?Rawlins
Hi there, a bit late but anyways git will consider email based link as ssh by default. and it expects only host not a protocol as urlOutrun
Not the right way to resolve the issue, does not work for me,got the fatal: 'git@***.****.com/xyz/abc.git' does not appear to be a git repository fatal: Could not read from remote repositoryPanlogism
I fixed it by removing ssh:// also from the pushurl config in the same fileUnforgettable
S
35

This worked for me. I had added google DNS server details in NetworkPreference.

8.8.8.8,8.8.4.4

https://developers.google.com/speed/public-dns/docs/using

Sang answered 30/7, 2016 at 19:55 Comment(5)
How to do it, please elaborate ?Sydelle
This worked for me. For instructions, see this linkDowndraft
Issues on my raspberry pi; had to update my /etc/dhcpcd.conf fileAlvinia
Although I found this solution myself not from this answer, it is a working one! What made me think its a DNS problem and not Git is that I could not reach the company websites (which are accessed by using VPN on the windows host, and the error appeared in a guest Ubuntu, where I used git)Pharyngo
then REBOOT ! works greate. thanks.Outlet
D
10

Add bitbucket.org to your host file

nano /etc/hosts

Add the bitbucket.org to the host file as shown below

104.192.143.1   bitbucket.org

a screenshot showing how the host file looks like

save the file and exit. bitbucket should be resolved.

Danica answered 4/4, 2018 at 2:30 Comment(2)
You are a lifesaver! Note that if you use Bitbucket Server or any other version control system on another IP you need to change the IP of courseQuietus
Though this might work, bitbucket can change it's IP's and then you're looking for an hour at why it's broken, not remembering you did this in your hostfile.Fumy
R
8

I don't know the exact cause for this issue.First thing to is to ping bitbucket.org. If you are getting response then follow that steps below.

Go to .git folder of you repo, use your favorite editor.open config file and change the url value as shown below.Worked for me.

https://bitbucket.org/<username>/<repo>  -> https://<username>@bitbucket.org/<username>/<repo>

Same steps will fix ssh issue also, Just add username.

In the picture is my notes repo , where i save all my notes enter image description here

Rhapsodist answered 30/1, 2016 at 13:54 Comment(3)
this works for me, I don't understand why occurs that. I git push before a lot of times today and then suddenly happens this.. Before my git config file was using the ssh:// protocol then I change for the https:// protocol. I just copy from bitbucket and everything works fine. Thanks allsyed.Encephalic
Same steps will fix ssh issue also, Just add username. Could you please provide an example, like for the https? Cause I am not sure it it's what I think.Lukasz
My setup(machine, OS) is now changed, don't have an example.Rhapsodist
F
6

Some answers have mentioned editing /etc/hosts. It didn't work for me, but led me toward the fix.

I was on a brand new WSL/Ubuntu install, and trying to clone my repo. I got the very same error message as OP. Additionally, I would get a similar error when pinging google.com, but I could ping 8.8.8.8 just fine.

Solution: edited /etc/resolv.conf and replaced the default nameserver with 8.8.8.8.

Fishwife answered 26/10, 2021 at 16:20 Comment(0)
C
4

Add following entry in host (including port number 22) on Windows OS

104.192.143.1:22   bitbucket.org

host file is located at C:\Windows\System32\drivers\etc

Carrillo answered 5/7, 2018 at 2:33 Comment(0)
C
3

The error message suggests a DNS or network issue. If this is a linux box you could investigate the output of a few networking commands such as ifconfig, host bitbucket.org, and follow some guides on troubleshooting DNS issues for your specific environment.

Chic answered 20/4, 2015 at 12:39 Comment(2)
host bitbucket.org ;; connection timed out; no servers could be reached ... this probably shouldn't happen right ?Townspeople
No you either have a network issue or your network is OK but you have no DNS working. When I run host bitbucket it tells me the IP addresses are blah blah - heres the first : 131.103.20.167. When I ping that I get replies. To test what your problem is next try to ping the IP above by issueing this command ping 131.103.20.167.Chic
F
3

I am using git through Linux Subsystem on Windows 10, and only the answer from @Saviour Dela above, worked for me. Process I followed is as follows:

  1. Get the IP to bitbucket, by ping bitbucket from Windows command prompt.
  2. Add the IP to the /etc/hosts file.
Fixer answered 13/5, 2018 at 11:32 Comment(0)
P
2

This seems a lot like the issue I'm facing. In my case the problem was related to IPv6 (for details see: Can't push/pull to bitbucket via SSH when behind VPN. IPv6 issue?). The workaround was to add AddressFamily inet to my .ssh/config file under the Host bitbucket entry, which forces that connection to use IPv4.

Pronoun answered 24/3, 2017 at 15:13 Comment(0)
F
2

I had the same problem until I turned off my VPN. I am not sure of the reason though I will be happy if someone explains.

Fontanez answered 26/8, 2019 at 5:2 Comment(2)
any solution when using vpn?Landre
Try that forcing it to you IPv4 insteady of IPv6Fontanez
U
2

I canceled in the middle of git push and then this started appearing. Doing a git pull && git fetch made it work again.

Unruly answered 8/1, 2020 at 17:20 Comment(0)
C
1

Alright, as I am getting the hang of git, I would like to attempt to provide feedback/cherry pick on the easy stuff. The error "can't pull/push from repository" typically happens if the user you are using does not have rights to push to the desired remote git repository. If you are new, this should be your origin.

Check SSH Agent:

  • Check Private Key: navigate to your present user's home directory, on linux this is ~/. In this directory check for the folder ~/.ssh. If it exists, you possibly have git setup correctly. Else, if the folder does not exist, find a useful tutorial online to help you setup git on your machine from start to finish.
  • Check Public Key: if you actually found a .ssh folder in your home directory, then look at the public and private keys. Log into your git account online, and navigate to your public key, compare that to the file ~/.ssh/id_rsa.pub. If the contents are the same, your machine should be communicating with the remote server without any issues.

Check Remote: you are here because you are certain that git is installed on your machine, and that your present private key has had it's corresponding public key copied into your online git account. But you may be pushing to the wrong location. First check the branch that you are working on, were you pushing the right branch? Type;

git branch

You should see your branches listed with the present branch highlighted or with an asterisk in front of the name. If you wish to be pushing a different branch, check it out and continue. Then, confirm that you have the right url in origin, type;

git remote -v

Use the given output to confirm that you were pushing to the right remote. If not type;

git remote remove <name>

and follow that with

git remote add <name> <url>

this way when you push your code using

git push <name> <branch>

Everything should be pushed accordingly.

If after checking the above steps, you find that you are still locked out. Note, I assumed that you have a working internet connection. I would obviously setup git from scratch - not the same as reinstalling it, just setup it up and make sure you note the user setting up, and the passphrase that you are using. You should be fine.


Example URL: [email protected]:username/repository_name.git

Cavendish answered 17/2, 2019 at 22:4 Comment(0)
E
0

As sreekumar said, the idea is to preset the DNS and it is detailed here

Changing DNS server settings on Windows 7

  1. Go to the Control Panel.
  2. Click Network and Internet > Network and Sharing Center > Change adapter settings.
  3. Select the connection for which you want to configure Google Public DNS. For example:
    • To change the settings for an Ethernet connection, right-click Local Area Connection > Properties.
    • To change the settings for a wireless connection, right-click Wireless Network Connection > Properties.
    • If you are prompted for an administrator password or confirmation, type the password or provide confirmation.
  4. Select the Networking tab. Under This connection uses the following items, select Internet Protocol Version 4 (TCP/IPv4) or Internet Protocol Version 6 (TCP/IPv6) and then click Properties.
  5. Click Advanced and select the DNS tab. If there are any DNS server IP addresses listed there, write them down for future reference, and remove them from this window.
  6. Click OK.
  7. Select Use the following DNS server addresses. If there are any IP addresses listed in the Preferred DNS server or Alternate DNS server, write them down for future reference.
  8. Replace those addresses with the IP addresses of the Google DNS servers:
    • For IPv4: 8.8.8.8 and/or 8.8.4.4.
    • For IPv6: 2001:4860:4860::8888 and/or 2001:4860:4860::8844.
    • For IPv6-only: you can use Google Public DNS64 instead of the IPv6 addresses in the previous point.
  9. Restart the connection you selected in step 3.
  10. Test that your setup is working correctly
  11. Repeat the procedure for additional network connections you want to change.
Everglades answered 11/1, 2017 at 11:14 Comment(0)
D
0

Just in case none of those answers helped, in my case I was using a "ghost" terminal session. The output of "whoami" was showing some unknown user, and the solution was to close and open a new console window.

Derinna answered 7/8, 2017 at 18:32 Comment(0)
P
0

In my case it happened because connection was behind proxi.

From command line sites were inaccessible(no ping). However via browsers bitbucket.org was available.

The solution was:

git config --global http.proxy http://proxi_ip_or_host:80
Poulard answered 3/5, 2019 at 7:11 Comment(1)
instead of 80 put your proxi portPoulard
B
0

Restarting my system actually worked for me after

Bodine answered 27/12, 2019 at 1:41 Comment(0)
B
0

I faced the same problem. I was using Ubuntu over Virtual Machine. Restarting the Virtual Machine solved the problem.

Betteann answered 8/7, 2021 at 7:10 Comment(0)
A
0

It might sound silly, but for me, this issue was happening BECAUSE MY INTERNET WAS OFF. So, please make sure, it is not a problem with your Wifi before you dig into the technical stuff...

Atonality answered 19/7, 2023 at 16:44 Comment(0)
S
-1

This basically means that you are unable to establish a connection with the bibucket because your network isnt allowing you to do so. Try installing the certificates and then use the "git clone" command to clone your repo. c:-->program files -->git -->usr -->ssl -->cer and install the certificates by clicking on ca-bundle and ca-bundle.trust Worked for me . Let me know how it helps you :-)

Schumacher answered 5/8, 2017 at 11:30 Comment(0)
H
-1

Guess what... using Visual Studio and Git Gui I got this same message from git: Could not resolve host: bitbucket.org. Then I went to bitbucket using Chrome on Mac OS and bitbucket was accessible.

In my case it was the Parallels Windows virtual machine that had no internet connection! :-)

So check your internet connection before anything. It can be a simple "no internet connection" problem.

enter image description here

Hebrides answered 6/11, 2018 at 23:35 Comment(0)
D
-1

As for me, I was getting this problem because the proxy settings on my machine. The minute I disabled the settings, it started to work.

Disserve answered 7/10, 2020 at 13:13 Comment(0)
M
-1

For linux - restarting the network may help:

sudo service networking restart
Milk answered 1/12, 2020 at 14:15 Comment(0)
P
-1

Only reason behind this is "Network issue" with your machine now verify your internet connectivity and troubleshoot that only not disturb ssh. it might be DNS, it might be IP, so just switching your Ip static, adding DNS or restarting the router may work for you.

Perjured answered 20/12, 2020 at 5:2 Comment(1)
Hello and welcome to SO! Please read the tour, and How do I write a good answer?Shakeup
F
-1

in my case, port 22 in my network blocked, so change the URl using this :

ssh://[email protected]:443/<account_name>/<repo_name>/

https://support.atlassian.com/bitbucket-cloud/docs/troubleshoot-ssh-issues/

Furtado answered 26/7, 2022 at 5:3 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Glendaglenden
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewGastronome
B
-1

Today Bitbucket started issuing me an IPv6 address which my Linux system doesn't work great with. I resolved this by forcing an IPv4 connections in ~/.ssh/config

Host example.com
  AddressFamily inet # inet=IPv4, inet6=IPv6, any=both
  ...
Bedlamite answered 25/10, 2022 at 5:24 Comment(0)
E
-1

In my case, I had AdGuard Windows (installed system-wide) that uses its own DNS server. Disabling AdGuard fixed the problem for me.

Under General Settings > DNS Exclusions, I added bitbucket.org.

Problem solved.

If you have similar apps, simply add bitbucket.org to the whitelist.

Errant answered 28/3, 2023 at 19:24 Comment(0)
C
-1

As for me, I just restart my windows console and git pull again.

Crosse answered 8/5, 2023 at 22:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.