'Constantly getting git error "port 22: Network is unreachable" with no clear cause

I'm using Fork as a git client. Recently, whenever I try to push/pull/fetch from a remote repository I get this error:

Pushing to bitbucket.org:(repository) ssh: connect to host bitbucket.org port 22: Network is unreachable fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

I first tried making a new ssh key and that seemed to fix the problem, but then it started up again. I then tried turning off my firewall/antivirus which also only worked for a day or two before I got the error once more. My internet connection is stable and I definitely have access to the remote repository I'm trying to connect to. I haven't tested it with any other repositories because this is the only one I actively need to use.

At this point, I have no idea what the problem could possibly be because it seems almost random when it does or doesn't work. Just now I attempted to push 3 times and I kept getting the error, and then suddenly it worked. Any help would be greatly appreciated, this is really starting to interfere with my team's workflow.



Solution 1:[1]

Assuming that issues like fork-dev/TrackerWin issue 923 have been fixed since 2020, I would switch, for testing, to an HTTPS URL in order to see if the issue persists

Using a git credential helper like "manager" (the GCM Git Credential Manager bundled with Git), you can cache your BitBucket credentials, and still pull/push like you were doing before with SSH.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 VonC