Troubleshooting
Solutions to common issues encountered when deploying with HostFn.
This page covers common problems you might encounter when using HostFn and how to resolve them.
rsync Not Installed
Error:
rsync is not installed on your system.Solution: Install rsync on your local machine:
| Platform | Command |
|---|---|
| macOS | brew install rsync |
| Ubuntu / Debian | sudo apt-get install rsync |
| CentOS / RHEL | sudo yum install rsync |
| Windows | Install via WSL and use sudo apt-get install rsync |
Rsync only needs to be on your local machine. The remote server does not need rsync installed -- HostFn uses rsync's SSH transport which handles the remote side automatically.
SSH Connection Failed
Error:
SSH connection failed: connect ECONNREFUSEDPossible causes and solutions:
-
Wrong host or port -- double-check the
serverfield in your config:"server": "ubuntu@your-server.com" -
SSH key not found -- verify your key exists:
ls -la ~/.ssh/id_ed25519 ~/.ssh/id_rsa ~/.ssh/id_ecdsa -
Key permissions too open -- SSH keys must have restricted permissions:
chmod 600 ~/.ssh/id_ed25519 chmod 700 ~/.ssh -
SSH agent not running -- if using passphrase-protected keys:
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519 -
Firewall blocking SSH -- check the server's firewall:
# On the server sudo ufw status sudo ufw allow 22 -
Test the connection manually -- verify you can connect outside of HostFn:
ssh ubuntu@your-server.com "echo connected"
Health Check Failed
Error:
Health check failed after 10 attempts
Service is not responding to health checksPossible causes and solutions:
-
No health endpoint -- make sure your application exposes a health endpoint:
src/index.ts app.get('/health', (req, res) => { res.json({ status: 'ok' }); }); -
Wrong port -- verify the
portin your config matches the port your application listens on:"port": 3000 -
Wrong health path -- verify the
health.pathmatches your endpoint:"health": { "path": "/health" } -
Application crashing on startup -- check the PM2 logs:
hostfn logs productionOr directly on the server:
ssh ubuntu@your-server.com "pm2 logs my-api-production --lines 50" -
Application starts slowly -- increase the retries and interval:
hostfn.config.json { "health": { "retries": 20, "interval": 5 } } -
Missing environment variables -- the app may crash because a required env var is not set:
hostfn env validate production
Deployment Lock
Error:
Deployment is already in progress
Started by: developer
Started at: 3/11/2026, 2:30:00 PM
Age: 2 minute(s)Solutions:
-
Wait for the current deployment to finish -- another deployment is genuinely in progress
-
Wait for the lock to expire -- locks auto-expire after 5 minutes
-
Remove the lock manually -- if you are certain no deployment is running:
ssh ubuntu@your-server.com "rm /var/www/my-api-production/.hostfn-deploy.lock" -
Prevent concurrent deployments in CI/CD -- use concurrency groups:
.github/workflows/deploy.yml concurrency: group: deploy-production cancel-in-progress: false
Build Failed
Error:
Build failed: <error output>Possible causes and solutions:
-
Missing dev dependencies -- if your build requires devDependencies, make sure
build.commandis set in your config. HostFn installs all dependencies (including dev) when a build command is configured:{ "build": { "command": "npm run build" } } -
Wrong Node.js version -- verify the
versionfield matches what your project needs:"version": "20" -
Build works locally but fails on server -- platform-specific issues. Check for:
- Native binary dependencies (e.g.,
sharp,better-sqlite3) - Path case sensitivity (Linux is case-sensitive, macOS is not by default)
- Environment variables needed during build
- Native binary dependencies (e.g.,
-
Out of memory -- the server may not have enough RAM. Check with:
ssh ubuntu@your-server.com "free -h"
PM2 Start Failed
Error:
PM2 start failed: <error output>Possible causes and solutions:
-
Wrong entry point -- verify
start.entrypoints to the correct file:{ "start": { "command": "npm start", "entry": "dist/index.js" } } -
Port already in use -- another process is using the configured port:
ssh ubuntu@your-server.com "lsof -i :3000"Kill the conflicting process or change the port in your config.
-
PM2 not installed -- HostFn installs PM2 automatically, but if it fails:
ssh ubuntu@your-server.com "npm install -g pm2" -
Check PM2 logs for the actual error:
ssh ubuntu@your-server.com "pm2 logs my-api-production --lines 100"
Nginx Configuration Test Failed
Error:
Nginx configuration test failedPossible causes and solutions:
-
Syntax error in generated config -- inspect the Nginx config:
ssh ubuntu@your-server.com "cat /etc/nginx/sites-available/my-api-production" -
Port conflict -- another Nginx server block is already listening on port 80/443 for the same domain:
ssh ubuntu@your-server.com "nginx -t"The output will show the exact error location.
-
Nginx not installed -- run server setup first:
hostfn server setup ubuntu@your-server.com -
Test Nginx manually:
ssh ubuntu@your-server.com "sudo nginx -t"
SSL Certificate Failed
Error:
SSL certificate provisioning failedPossible causes and solutions:
-
DNS not configured -- your domain must point to the server's IP address before requesting an SSL certificate. Verify with:
dig +short your-domain.comThe result should be your server's IP address.
-
Let's Encrypt rate limits -- Let's Encrypt limits certificate requests. If you hit the limit, wait and try again later. See Let's Encrypt rate limits.
-
Port 80 blocked -- Let's Encrypt needs port 80 to be accessible for HTTP-01 challenges:
ssh ubuntu@your-server.com "sudo ufw allow 80" -
Certbot not installed -- run server setup:
hostfn server setup ubuntu@your-server.com
General Debugging Tips
Check the deployment from the server
SSH into the server and inspect the deployment directory:
ssh ubuntu@your-server.com
# Check the deployment directory
ls -la /var/www/my-api-production/
# Check PM2 processes
pm2 list
# Check PM2 logs
pm2 logs my-api-production
# Check Nginx status
sudo systemctl status nginx
# Check Nginx error logs
sudo tail -f /var/log/nginx/error.logTest locally first
Before deploying, make sure your application builds and runs locally:
npm run build
npm start
curl http://localhost:3000/healthUse dry run mode
Preview what a deployment would do without making changes:
hostfn deploy production --dry-runCheck server resources
Ensure the server has enough resources:
ssh ubuntu@your-server.com "df -h" # Disk space
ssh ubuntu@your-server.com "free -h" # Memory
ssh ubuntu@your-server.com "nproc" # CPU cores