IPFS (InterPlanetary File System) provides decentralized, content-addressed file storage and distribution — commonly used alongside blockchain applications for storing larger data off-chain. This guide covers setting up an IPFS node.
What IPFS Provides
Rather than location-based addressing (a URL pointing to a specific server), IPFS uses content-based addressing — files are identified by a hash of their content, and can be retrieved from any node that has them, providing genuine decentralization and content integrity verification.
Why This Matters for Blockchain Applications
Storing large files directly on-chain is prohibitively expensive on most blockchains — a common pattern stores only a content hash on-chain, with the actual file content hosted on IPFS, combining blockchain's integrity guarantees with more practical off-chain storage economics.
Step 1 — Install IPFS (Kubo, the Reference Implementation)
wget https://dist.ipfs.tech/kubo/v0.28.0/kubo_v0.28.0_linux-amd64.tar.gz
tar -xzf kubo_v0.28.0_linux-amd64.tar.gz
cd kubo
sudo bash install.sh
Step 2 — Initialize the IPFS Repository
ipfs init
Step 3 — Start the IPFS Daemon
ipfs daemon
Step 4 — Add a File to IPFS
ipfs add myfile.txt
Returns a content hash (CID) — this hash is now the permanent, content-based identifier for that exact file content, retrievable from any IPFS node that has pinned or cached it.
Step 5 — Retrieve Content by Hash
ipfs cat QmHashHere
Running IPFS as a systemd Service
[Unit]
Description=IPFS daemon
After=network.target
[Service]
ExecStart=/usr/local/bin/ipfs daemon
Restart=always
User=ipfs
[Install]
WantedBy=multi-user.target
Pinning Content to Ensure Persistence
ipfs pin add QmHashHere
Content not pinned may be garbage-collected by your node over time — pinning ensures content you specifically want to keep available remains stored, essential for content you're responsible for hosting reliably.
Configuring firewalld/ufw for IPFS's Ports
sudo ufw allow 4001/tcp
sudo ufw allow 4001/udp
IPFS's swarm port needs to be reachable for your node to properly participate in the peer-to-peer network, both providing and retrieving content effectively.
Securing the IPFS API
By default, the IPFS API (distinct from the swarm/content-serving port) should not be exposed publicly — it provides significant node management capability; restrict access similarly to other administrative interfaces covered throughout this Knowledge Base.
Considering Storage Growth
Pinned content accumulates on your node's storage over time — monitor disk usage (see general disk monitoring practices) and establish a policy for what content genuinely needs long-term pinning versus what can be allowed to be garbage collected.
Common Errors
Content not retrievable by others despite being added locally — verify your node's swarm port is genuinely reachable from the internet (not blocked by firewall/NAT), since IPFS content retrieval depends on your node being reachable as a peer.
Continue Reading
- How to Run a Local Blockchain Explorer
- How to Secure a Cryptocurrency Node on a VPS
- VPS Requirements for Running a Blockchain Node
Browse more articles in Cryptocurrency & Blockchain Node Hosting.