Question

I'd like to clone remote repository, add file and push file back but getting exception:

org.eclipse.jgit.api.errors.TransportException: git://192.168.1.1/abc: Connection refused: connect
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:137)
    at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:178)
    at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125)

Code is:

UsernamePasswordCredentialsProvider user = new UsernamePasswordCredentialsProvider(userId, userPass);
File workingCopy = new File(REPO_PATH);
Git.cloneRepository().setCredentialsProvider(user).setURI(uri).setDirectory(workingCopy).setBranch("master").setBare(false).setRemote("origin").setNoCheckout(false).call();

Now remote repo is on localhost, and when I use "localhost" in path everything works fine and when use IP address I'm getting exception like above. Port 9418 is unlocked.

Any ideas? Thanks in advance.

Was it helpful?

Solution

If you get a "Connection Refused" error message, that (normally) means that no service was listening on IP address + port that your client was trying to connect to.

A common trick for confirming this problem is using some other utility to attempt to connects to the problem IP + port. The telnet utility is commonly used for this. Install it (if necessary) and check the manual entry to find the command line options for specifying the port number. (It will depend on your OS ...)

Given that you say that localhost works, and the port you are using is not blocked by your local firewall, the most likely explanation is that you have only configured your Git server software to listen on the localhost IP address (typically 127.0.0.1)

OTHER TIPS

It doesn't make sense to set a credentials provider for git protocol since it's anonymous

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top