Skip to main content

Understanding Exit Codes

Exit codes provide detailed information about why a script failed. Each code maps to a specific error condition, making troubleshooting faster and more precise.
Exit code 0 always indicates success. Non-zero codes indicate various types of failures.

Quick Reference Chart

Exit Code RangeCategoryTypical Issue
1-2, 126-143Shell/SystemPermissions, signals, missing commands
100-102Package ManagerAPT/DPKG errors, broken packages
103-125Script ValidationEnvironment checks, prerequisites
160-162Python/pipVirtual environments, dependencies
170-193DatabasesConnection, authentication, query errors
200-209Container CreationCTID, password, configuration
210-217Storage/ClusterDisk space, quorum, storage type
218-225TemplatesDownload, corruption, availability
231-238Tools/AddonsTool-specific errors
243-249Node.js/npmRuntime errors, memory issues
250-254ApplicationDownload, extraction, migration

Generic Shell Errors (1-2, 126-143)

Standard Unix/Linux exit codes used across all scripts.
# Exit Code 1 - General error / Operation not permitted
# Cause: Permission denied, general failure
# Solution: Check user permissions, run as root if needed

# Exit Code 2 - Misuse of shell builtins
# Cause: Syntax error in script
# Solution: Review script syntax, check bash version
CodeDescriptionCommon CausesSolutions
1General error / Operation not permittedPermission denied, general failureCheck user permissions, run as root if needed
2Misuse of shell builtinsSyntax error in scriptReview script syntax, check bash version
126Command cannot executePermission problem, not executablechmod +x script.sh or check file permissions
127Command not foundMissing binary, wrong PATHInstall required package, check PATH variable
128Invalid argument to exitInvalid exit code passedUse exit codes 0-255 only
130Terminated by Ctrl+C (SIGINT)User interrupted scriptExpected behavior, no action needed
137Killed (SIGKILL)Out of memory, forced terminationCheck memory usage, increase RAM allocation
139Segmentation faultMemory access violation, corrupted binaryReinstall package, check system stability
143Terminated (SIGTERM)Graceful shutdown signalExpected during container stops

Package Manager Errors (100-102, 255)

APT, DPKG, and package installation errors.
Common Causes:
  • Broken packages
  • Dependency conflicts
  • Failed installations
Solutions:
# Fix broken packages
apt --fix-broken install

# Reconfigure packages
dpkg --configure -a

# Update and retry
apt update
apt upgrade
Common Causes:
  • Malformed sources.list
  • Bad repository configuration
  • Invalid GPG keys
Solutions:
# Check sources.list
cat /etc/apt/sources.list
cat /etc/apt/sources.list.d/*.list

# Fix and update
apt update
Common Causes:
  • Another apt/dpkg process running
  • Stale lock files
Solutions:
# Check running processes
ps aux | grep -E 'apt|dpkg'

# If safe to remove locks:
rm /var/lib/dpkg/lock-frontend
rm /var/lib/dpkg/lock
dpkg --configure -a
Only remove lock files if no package manager processes are running.
Common Causes:
  • Corrupted package database
  • System inconsistency
Solutions:
# Reconfigure all packages
dpkg --configure -a

# If needed, restore from backup
# Check /var/backups/dpkg.status.*

Script Validation Errors (103-125)

Environment checks and prerequisite validation.
CodeDescriptionSolution
103Shell is not BashUse bash to run the script
104Not running as rootRun with sudo or as root user
105Proxmox VE version not supportedUpgrade Proxmox VE
106Architecture not supported (ARM/PiMox)Use x86_64 architecture
109No available container ID after max attemptsManually specify CTID
116Default bridge vmbr0 not foundConfigure network bridge
117Container did not reach running stateCheck container logs
118No IP assigned to containerCheck DHCP/network config
119No valid storage for rootdirConfigure compatible storage
122No internet connectivityCheck network and routing

Container Creation Errors (200-209)

Errors during LXC container creation.
Problem: Container ID is below the minimum allowed value.Solution: Use CTID ≥ 100. Container IDs 1-99 are reserved for Proxmox system use.
Problem: A container or VM with this ID already exists.Solutions:
# Check existing containers
pct list

# Check for ghost containers
ls /etc/pve/lxc/

# Use a different CTID
If a container appears in /etc/pve/lxc/ but not in pct list, manually remove the config file.
Problem: Password validation failed due to unescaped special characters.Problematic Characters: Special characters at start/end: -, /, \, *, !, @Solution: Use alphanumeric passwords or avoid leading/trailing special characters.
Common Issues:
  • DNS format: .home instead of home (remove leading dot)
  • MAC format: AA-BB-CC instead of AA:BB:CC (use colons)
  • Invalid IP address format
Solution: Verify all configuration parameters follow correct format.
Problem: General container creation failure.Solutions:
# Check detailed logs
tail -n 50 /tmp/pct_create_*.log

# Verify template
pveam list local

# Check storage
pvesm status

Storage & Cluster Errors (210-217)

Problem: Cluster doesn’t have enough nodes online.Solutions:
# Check cluster status
pvecm status

# For single-node testing (temporary)
pvecm expected 1
Solutions:
# Check storage
pvesm status
df -h

# Free up space
# - Remove old backups
# - Remove unused templates
# - Clean logs
Problem: Selected storage type doesn’t support LXC containers.Incompatible Storage:
  • iscsidirect (VMs only)
  • cephfs (use RBD instead)
  • pbs (backups only)
Compatible Storage:
  • dir, zfspool, lvm-thin, rbd

Template Errors (218-225)

Common Causes:
  • Download interrupted
  • File size < 1MB
  • Invalid archive format
Solutions:
# Remove corrupted template
rm /var/lib/vz/template/cache/<template>

# Re-download
pveam update
pveam download local <template>
Problem: Template download failed after 3 attempts.Solutions:
# Check connectivity
ping download.proxmox.com

# Verify storage
pvesm status
df -h

# Update and retry
pveam update
Problem: Template not available for specified OS/version.Solutions:
# Update template list
pveam update

# Check available templates
pveam available --section system

Database Errors

# Exit Code 170 - Connection failed
systemctl status postgresql
systemctl start postgresql

# Exit Code 171 - Authentication failed
# Check pg_hba.conf and credentials

# Exit Code 172 - Database does not exist
CREATE DATABASE dbname;

# Exit Code 173 - Fatal error in query
# Review SQL syntax and constraints

Node.js/npm Errors (243-249)

Problem: JavaScript heap exhausted.Solutions:
# Increase memory limit
export NODE_OPTIONS="--max-old-space-size=4096"

# Allocate more RAM to container
pct set <CTID> -memory 4096
Solutions:
# Update Node.js
# Check for known bugs in Node.js version
# Review application logs
Solutions:
# Clear cache
npm cache clean --force

# Reinstall package manager
npm install -g npm@latest

Python/pip Errors (160-162)

Solutions:
# Recreate virtualenv
python3 -m venv venv
source venv/bin/activate
Problem: EXTERNALLY-MANAGED or permission denied.Solutions:
# Use virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate
pip install <package>

# Or use --break-system-packages (with caution)
pip install --break-system-packages <package>

Application Errors (250-254)

CodeDescriptionCommon Solution
250Download failed or version not determinedCheck network, verify URL
251File extraction failedVerify archive integrity
252Required file or resource not foundCheck installation path
253Data migration requiredFollow migration guide
254User declined prompt or timeoutReview and accept prompts

Troubleshooting Tips

Finding Error Details

# View creation logs
tail -n 50 /tmp/pct_create_*.log

# View installation logs
tail -n 50 /tmp/install-*.log

# View persistent logs (if debug mode enabled)
tail -f /var/log/community-scripts/*.log

Common Patterns

Exit 0 with error message: Configuration validation failed (check DNS, MAC, password format)Exit 206 but container not visible: Ghost container state - check /etc/pve/lxc/ manuallyExit 209 generic error: Check /tmp/pct_create_*.log for specific pct create failure reasonExit 218 or 222: Template issues - delete and re-download template

See Also

  • Common Issues - Detailed solutions for frequent problems
  • Debug Mode - Enable verbose logging and tracing
  • Logs - Log file locations and analysis

Build docs developers (and LLMs) love