Garbage Collector and IPFS Pinning

This is my first time exploring IPFS. My biggest confusions at the moment are around how the garbage collector works and how IPFS pinning works.

For instance, if I build a decentralized Spotify, and post music on IPFS - what would the conditions be for the garbage collector to delete the files? Is it possible, that if a user tries to access it, the file is gone?

On top of that, regarding ipfs pinning, the docs mentioned that “pinning” an item is essentially marking it for the garbage collector not to delete it, so it will not deleted. Am I correct in this assumption?

More specifically, how exactly does IPFS pinning work as a whole? Whatever the file is, if pinned - does that mean it’s pinned on most nodes or just the node that pushes it? If it’s the former, then wouldn’t there be scaling issues with too many files marked as un-deletable? If it is the latter, wouldn’t this mean that the initial node has to be up and running to be able to access the file? Would this then be a centralized solution?

In some threads here, I also read that by adding a file through ipfs, you are automatically pinning it to your node. Can I get some clarification on this? If ipfs add <file> keeps the file always accessible, then what’s the difference between this and pinning it?


Correct :slight_smile:

Just your node. Every IPFS node has its own independent set of pins. You decide what is pinned on your node, nobody can force you to do so. If you have multiple nodes under your control you can coordinate pinning using IPFS Cluster (

This is similar to how BitTorrent works: there needs to be at least one seed for data to be available to the network. Just like with pins, every node decides what content is fetched and seeded (co-hosted). If nobody else cares about your data, the data will be “forgotten”.

When you add local data via ipfs add it will be pinned by default, so the data you care about won’t be garbage collected. You can also manually ipfs pin data that is already on IPFS to help with co-hosting it.

To be more specific, the API is ipfs.files.add(data, [options]) and one of default options is pin=true.
You can override that behaviour by passing pin=false in options.
That way data will be added to IPFS, but won’t be pinned.