How to run several IPFS nodes on a single machine?
Usually, when you start with IPFS, you will use ipfs init
, which will create a new node. The default data and config stored for that particular node are located at ~/.ipfs
. Here is how you can create a new node and config it so it can run besides your default node.
1. Create a new node
For a new node you have to use ipfs init
again. Use for instance the following:
IPFS_PATH=~/.ipfs2 ipfs init
This will create a new node at ~/.ipfs2 (not using the default path).
2. Change Address Configs
As both of your nodes now bind to the same ports, you need to change the port configuration, so both nodes can run side by side. For this, open ~/.ipfs2/configand find
Addresses`:
"Addresses": {
"API": "/ip4/127.0.0.1/tcp/5001",
"Gateway": "/ip4/127.0.0.1/tcp/8080",
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001"
]
}
To for example the following:
"Addresses": {
"API": "/ip4/127.0.0.1/tcp/5002",
"Gateway": "/ip4/127.0.0.1/tcp/8081",
"Swarm": [
"/ip4/0.0.0.0/tcp/4002",
"/ip6/::/tcp/4002"
]
}
With this, you should be able to run both node .ipfs and .ipfs2 on a single machine.
Notes:
- Whenever you use .ipfs2, you need to set the env variable
IPFS_PATH=~/.ipfs2
- In your example you need to change either your client or server node from ~/.ipfs to ~/.ipfs2
- you can also start the daemon on the second node using IPFS_PATH=~/.ipfs2 ipfs daemon &