Common Issues and Solutions
This page covers common problems you may encounter when using the P2P file sharing system and how to resolve them.Connection Refused Error
Connection Refused Error
Error Message:Cause: The remote peer is not listening on the specified port, or the host/port is incorrect.Solutions:
- Verify the peer is running and listening on the correct port
- Check that you’re using the correct host and port in your
--peerargument - Ensure no firewall is blocking the connection
- Try connecting to
127.0.0.1instead oflocalhostif testing locally
Hash Mismatch / File Corruption
Hash Mismatch / File Corruption
Error Message:Cause: The downloaded file’s SHA-1 hash doesn’t match the original file’s hash from the seeder.Solutions:
- Delete the corrupted file and restart the download
- Ensure the seeder has a valid, uncorrupted source file
- Check for network issues that may have corrupted data during transmission
- If the problem persists, try downloading from a different seeder
Peer Has Different File Hash
Peer Has Different File Hash
Error Message:Cause: You’re trying to connect to a peer that’s sharing a different file.Solutions:
- Ensure all peers in the network are sharing the same file
- Verify you’re connecting to the correct seeder
- Check that the seeder hasn’t changed the file after starting
No Initial Peer and Not a Seeder
No Initial Peer and Not a Seeder
Warning Message:Cause: You started a leecher without the file and without specifying a
--peer to connect to.Solutions:- Restart with the
--peer <host:port>argument pointing to a seeder - Wait for a seeder to connect to your node (if they know your address)
- Ensure at least one seeder is running before starting leechers
Malformed JSON Message
Malformed JSON Message
Error Message:Cause: Network corruption or protocol version mismatch between peers.Solutions:
- Ensure all peers are running the same version of the software
- Check network stability
- Restart the affected peer
- This is usually a transient error and will auto-resolve
Requested Piece Not Available
Requested Piece Not Available
Warning Message:Cause: A peer requested a piece that this node doesn’t have yet.Impact: This is usually benign - the requesting peer will get the piece from another source.Solutions:
- No action needed - this is handled automatically
- If it happens frequently, check that bitfield messages are being sent correctly
Port Already in Use
Port Already in Use
Error Message:Cause: Another process is already using the specified port.Solutions:
- Choose a different port with
--port <different_port> - Stop the other process using that port
- On Linux/Mac, find the process:
lsof -i :<port>ornetstat -ano | grep <port> - On Windows:
netstat -ano | findstr <port>
File Opening Errors
File Opening Errors
Error Message:Common Causes:
- File path doesn’t exist (for seeders)
- No permission to read the file (for seeders)
- No permission to create/write the file (for leechers)
- Disk full (for leechers)
- Verify the file path is correct and absolute
- Check file permissions:
ls -l <file>on Linux/Mac - Ensure you have write permissions in the destination directory
- Free up disk space if needed
- Use quotes around file paths with spaces:
--file "/path/with spaces/file.ext"
Connection Drops During Download
Connection Drops During Download
Symptom: Download progress stalls, connection messages show peers disconnecting.Console Output:Causes:
- Network instability
- Seeder stopped running
- Firewall killed idle connections
- Ensure at least one seeder stays online throughout the download
- Connect to multiple peers for redundancy
- Check network stability
- Pending pieces will be automatically re-requested from other peers
Hash Computation Errors
Hash Computation Errors
Error Message:Cause: File system error or corrupted file preventing hash calculation.Solutions:
- Check that the file is not locked by another process
- Verify disk integrity
- Ensure you have read permissions on the file
- Try restarting the node
Invalid Arguments
If you see the usage message, you provided invalid arguments:- Missing required arguments (
--portand--fileare mandatory) - Invalid
--peerformat (must behost:port) - Invalid port number (must be numeric)
Firewall and Network Issues
Testing Locally
For testing on the same machine:Firewall Configuration
If peers cannot connect over a network: Linux (ufw):- Open Windows Defender Firewall
- Click “Advanced settings”
- Create new Inbound Rule
- Choose Port → TCP → Specific local ports: 6881,6882
- Allow the connection
Unknown Message Types
Warning Message:- Usually indicates version mismatch between peers
- Ensure all peers run the same software version
- This warning can typically be ignored if downloads work
Getting Help
If you encounter issues not covered here:- Check the Architecture page to understand how the system works
- Review the Protocol Messages documentation
- Enable verbose logging by checking console output carefully
- Verify Node.js version is 22 or higher:
node --version