I’ve followed the tutorial on hosting a git-style repository on ipfs, however when I try to clone the repo with the given command (git clone http://QmX679gmfyaRkKMvPA4WGNWXj9PtpvKWGPgtXaF18etC95.ipfs.localhost:8080/ myrepo)
it doesn’t seem to work. I get a fatal error and git says it is unable to resolve the host QmX679gmfyaRkKMvPA4WGNWXj9PtpvKWGPgtXaF18etC95.ipfs.localhost.
What am I doing wrong? Or is there a configuration step before I can follow this tutorial that I might’ve missed?
I set up the ipfs node with init and then ran the daemon. Everything else I did is in the Store & play videos | IPFS Docs tutorial.
I tried to convert it the way you showed, but I still get the error. It can’t seem to find it, even though I can get it in my browser no problem. Anything else I could try to look into, that might help?
I find it strange that it’s unable to resolve localhost! Glad it’s working in the browser, but I’m not sure why your terminal doesn’t want to resolve localhost :S. Do you maybe have a git configuration that could be interfering?
For example, I can’t even get “unable to resolve host” even with git clone http://this.isnot.valid.localhost.
I’m glad the tutorial is of interest , I found it helpful for learning about how CIDs are made.
Browsers have magic to resolve these localhost-subdomains. Try http://localhost:8080/ipfs/bafybeieb75o7544uiy4yjl3bhyy3xlevxtwsczkwktflrgqs2n6xjjahba/myrepo instead.
git clone http://localhost:8080/ipfs/$hash$ somefolder
Cloning into 'somefolder'...
fatal: unable to access 'http://localhost:8080/ipfs/$hash$/': Could not resolve host: $hash$.ipfs.localhost
I have no clue what the problem could be, I’m too new to IPFS as a whole.
Check if you have configured your IPFS gateway as a subdomain gateway (UseSubdomains: true). I don’t think it should be redirecting to the <cid>.ipfs.localhost url by default.
(this way you don’t need to use subdomais on localhost)
alternative global fix: configure your OS (assuming Linux?) to support subdomains on localhost (eg. via nss-myhostname)
alternative ad-hoc fix: use go-ipfs as HTTP proxy (export HTTP_PROXY=http://127.0.0.1:8080). Caveat: it only resolves IPFS resources over HTTP (localhost gateway), you won’t be able to browse the regular web with this.
When in hurry, just do the TLDR one.
Explainer:
localhost gateway is a subdomain gateway that redirects requests for /path/{cid} to a {cid}.ipfs.localhost DNS name
before it was hardcoded in browsers, we used HTTP proxy mode for avoiding DNS lookups; this is still supported
one can use regular path gateway on local machine by using 127.0.0.1:8080 endpoint
subdomain isolation does not provide any value outside of browser, so no reason to use localhost for git use case – just use 127.0.0.1 and the problem will go away
I’m on a windows machine, so I didn’t test the subdomain solution, though I might try it, if there is a way to do it on win10 as well. But the TLDR version solved it!