Troubleshooting & FAQ
Build failures, runtime crashes, database connection issues, certificate errors — and the quickest way out of each one.
Build errors
CMake cannot find OpenSSL or Zlib
Symptom: Could NOT find OpenSSL or Could NOT find ZLIB during configure.
macOS:
brew install openssl zlib brotli
export OPENSSL_ROOT_DIR="$(brew --prefix openssl)"
cmake .. -DOPENSSL_ROOT_DIR="$OPENSSL_ROOT_DIR"Ubuntu:
sudo apt-get install -y openssl libssl-dev zlib1g-dev libbrotli-devFetchContent fails to download Asio
Symptom: Build hangs or errors during Asio download step.
Fix: Download Asio manually and place it in the project root, or unzip the bundled asio.zip file:
cd /path/to/paozhu
unzip asio.zip
# or: curl -L https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-28-0.tar.gz | tar xz --strip-components=1
cmake ..Compile errors when enabling optional modules
Symptom: Build fails after turning on -DENABLE_PDF=ON or other feature flags.
Fix: Some optional modules require additional system libraries or bundled code that may be missing in a minimal clone. Run git submodule update --init --recursive if needed, or check that the module source directory is present. If using SQLite (-DENABLE_SQLITE=ON), ensure the SQLite amalgamation header/source is included.
ThreadSanitizer conflicts with Debug build
Symptom: ENABLE_TSAN and CMAKE_BUILD_TYPE=Debug fatal error.
Fix: ASan is auto-enabled for Debug builds. Use a non-Debug type for TSAN:
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_TSAN=ONvcpkg toolchain not found on Windows
Symptom: ENABLE_VCPKG is ON but VCPKG_ROOT is not set.
Fix: Set the environment variable or pass the toolchain file directly:
$env:VCPKG_ROOT = "C:\path\to\vcpkg"
cmake -B build -DENABLE_VCPKG=ON -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"Runtime issues
Address already in use on port 80 or 443
Symptom: bind() failed: Address already in use.
# macOS / Linux
sudo lsof -i :80
sudo lsof -i :443
# then kill the PID, or change port in server.confOn Linux, you can also use ss -tlnp | grep ':80'. Common culprits: Apache, nginx, or a previous paozhu instance still running.
Permission denied binding to port 80/443
Symptom: bind() failed: Permission denied on Linux.
Fix: Bind to a high port (e.g. 8080) in server.conf and put a reverse proxy (nginx) in front. Or run with sudo (not recommended for production) or set setcap 'cap_net_bind_service=+ep' bin/paozhu.
Config file paths are hardcoded to /Users/hzq/paozhu
Symptom: Server cannot find wwwroot, log directory, or other resources on your machine.
Fix: Open conf/server.conf and conf/orm.conf. Replace every occurrence of /Users/hzq/paozhu with your actual project path — wwwpath, logpath, temppath, and any SQLite database paths.
Hosts file missing — virtual domain not resolving
Symptom: Visiting your virtual domain returns the default site or "connection refused".
Fix: For local development, add a hosts entry:
sudo vim /etc/hosts
# add: 127.0.0.1 www.yourdomain.comProduction domains need A records pointing to your server IP.
Logs disappear when daemon mode is on
Symptom: You started with deamon_enable = 1 and can no longer see console output.
Fix: Check the log/ directory. The server writes to per-process log files there. Use tail -f log/* to follow. For foreground logs in dev, set deamon_enable = 0.
.so hot reload not picking up changes
Symptom: Controller or view .so rebuild didn't take effect.
Fix: Touch the reload trigger or send SIGHUP:
touch log/restart_server
# or send signal to the running paozhu PID
kill -HUP $(pgrep -f paozhu)Database & ORM issues
ORM config tag doesn't match generated code
Symptom: Runtime error like orm tag 'cms' not found in orm.conf.
Fix: Every model Foo.cpp generated by the CLI uses an ORM tag. Ensure that tag exists as a section header in conf/orm.conf — e.g. [cms] section must exist if any model is tagged cms.
MySQL connection fails with SSL handshake errors
Symptom: SSL connection error or handshake failures.
Fix: In orm.conf, set usessl = 0 if your MySQL server doesn't require SSL. Or provide sslca, sslcert, sslkey paths.
PostgreSQL build fails due to missing libpq
Symptom: CMake can't find PostgreSQL client library.
Fix:
# macOS
brew install postgresql
# Ubuntu
sudo apt-get install libpq-dev postgresql-clientRedis module build errors
Symptom: -DENABLE_REDIS=ON fails to compile.
Fix: The Redis client depends on hiredis. Install it with your package manager, or ensure the bundled source is present.
ORM model not regenerating after schema change
Symptom: New columns missing from C++ model class, or compile errors.
Fix: Re-run the CLI for each affected tag:
./bin/paozhu_cli orm cms
./bin/paozhu_cli orm lite
# then rebuild
cd build && make -j8ACME & certificate issues
ACME challenge fails — port 80 must be reachable
Symptom: HTTP-01 challenge failed during certificate issuance.
Fix: ACME HTTP-01 validation requires port 80 to be reachable from the public internet on the domain being validated. Make sure port forwarding / security groups are open. Paozhu must be running on that port for the challenge to succeed.
Certificate paths wrong in server.conf
Symptom: TLS handshake fails, server won't start in HTTPS mode.
Fix: For each [domain] section, verify ssl_cert_file and ssl_key_file point to existing files. After ACME auto-issue, certificates are stored in conf/acme_certs/.
ACME auto-renew not working
Symptom: Certificates expire without renewal.
Fix: Set acme_auto = 1 in the domain section. The renew thread runs every ~12 hours and renews certs with less than 30 days remaining. Check log/ for ACME log entries.
HTTP/2 & protocol issues
HTTP/2 not negotiated in browser
Symptom: curl -I https://yoursite/ shows HTTP/1.1, not HTTP/2.
Fix: Ensure http2_enable = 1 in the domain section. HTTP/2 is only negotiated over TLS. Verify with curl --http2 -I https://yoursite/.
H2C (cleartext HTTP/2) not working
Symptom: HTTP/2 over plain TCP fails.
Fix: Enable h2c explicitly with http2h2c_enable = 1. Most browsers only support HTTP/2 over TLS — test with curl --http2-prior-knowledge http://yoursite:port/.
Performance & rate limiting
Benchmark tool returns 429 or slow results
Symptom: ab or h2load gets throttled mid-run.
Fix: The framework has two-stage rate limiting enabled by default. For accurate benchmarks, either disable it in server.conf or run with -DENABLE_BENCHMARK=ON (the rate limiter is automatically disabled in benchmark mode).
Worker pool starved — requests time out
Symptom: Requests pile up, response latency increases under load.
Fix: Increase worker_pool_size in server.conf. The default worker pool is small; raise it to match your CPU cores for CPU-bound work, or even higher if requests spend time waiting on I/O.
Should I put code in coroutine or on a worker thread?
Answer: CPU-heavy work always goes on a worker thread. I/O-bound operations (database with async_fetch, HTTP client co_await, sleep/timer) belong in coroutines. If you block a coroutine, you block the entire I/O pool.
6b. C++ crash debugging & stack traces
Paozhu ships with AddressSanitizer (ASan) and all compiler warnings enabled. ASan fires on buffer overflows, use-after-free, double-free, and prints the exact file + line. In release mode where ASan is off, you get core dumps instead — here is how to read them.
AddressSanitizer (debug builds)
ASan is auto-enabled for Debug builds. GCC flags are already set to -Wall -Werror -fsanitize=address -O3. When ASan detects an error it prints a stack trace pointing to the offending line.
# Debug build (ASan auto-enabled)
cmake .. -DCMAKE_BUILD_TYPE=Debug
make -j8Release build with debug symbols (-g)
For production debugging compile with -g to keep debug symbols. This lets GDB resolve function names and line numbers from core dumps.
# Option 1: standard release
cmake .. -DCMAKE_BUILD_TYPE=Release
# Option 2: release + debug info for production debugging
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_GD=ONInstall gdb + coredumpctl
sudo apt install systemd-coredump gdb # Debian/Ubuntu
sudo dnf install systemd-coredump gdb # Rocky/AlmaLinux
brew install gdb # macOS (no coredumpctl)Capture current thread stack
Paozhu checks every ~60 seconds for a log/restart_server sentinel file. Touching it causes a clean restart — useful for collecting a thread snapshot before doing live analysis with GDB.
# List all threads
pstree -aup
# Force restart and capture before crash
touch log/restart_serverAnalyze a core dump with GDB
# List all available core dumps
coredumpctl list
# Show details for a core
coredumpctl info
# Launch GDB on a specific core (PID from 'pstree -aup' or 'coredumpctl list')
coredumpctl gdb 1524Once inside GDB, print backtraces for every thread and save to a file for analysis:
# Print the current thread's backtrace
bt
# Print backtraces for ALL threads
thread apply all bt
# Save all thread backtraces to a file
set logging file thread_info.txt
set logging enabled on
thread apply all bt
set logging enabled offExample output from GDB with -g symbols — shows every thread's current stack frame with source file and line number:
Thread 17 (Thread 0x7fd9f16b9640 (LWP 10658)):
#0 http::hash_objkey (key="data:image/php;base64,...") at vendor/httpserver/src/request.cpp:54
#1 http::obj_val::operator[] (...) at vendor/httpserver/src/request.cpp:315
#2 http::httpparse::procssxformurlencoded (...) at vendor/httpserver/src/http_parse.cpp:389
#3 http::httpparse::process (...) at vendor/httpserver/src/http_parse.cpp:28236c. "Too many open files" — file descriptor limits
When log/error.log shows Too many open files, the OS has hit its per-process socket/file limit (default is usually 1024). Here's how to diagnose and raise it.
Check current limits
# Check system-wide default
ulimit -n
# Count open file descriptors for a running paozhu process
PID=$(pgrep -f paozhu | head -1)
sudo ls -l /proc/$PID/fd | wc -l
# Or: sudo ls -l /proc/$PID/fd | tail -20Raise the system-wide limit
# format: domain type item value
* soft nofile 65535
* hard nofile 65535
# After editing, log out and log back in, or:
ulimit -n 655356d. Linux OOM Killer — "Out of memory"
When traffic spikes, paozhu may consume enough memory to exhaust the host. Linux then invokes the Out-Of-Memory Killer, which selects the largest process and terminates it. The paozhu binary is typically the victim.
Confirm an OOM kill happened
# Check system journal for OOM entries
sudo dmesg -T | grep -C 5 "paozhu"
dmesg -T | grep -i "killed process" | grep paozhu
# Or on systemd hosts:
journalctl -k | grep -i "oom"Typical output — paozhu is the killed process name:
__vm_enough_memory: pid: 1416222, comm: paozhu, not enough memory for the allocation
Out of memory: Kill process 1416222 (paozhu) score 900 or sacrifice child
Killed process 1416222 (paozhu) total-vm:...Fix: increase Swap space
# 1. Check current swap
sudo swapon --show
# 2. Disable existing swap file
sudo swapoff /swap.img
# 3. Create a larger one (8G example)
sudo rm /swap.img
sudo fallocate -l 8G /swap.img
sudo chmod 600 /swap.img
sudo mkswap /swap.img
# 4. Enable it
sudo swapon /swap.img
# 5. Persist across reboots (add to /etc/fstab if missing)
echo '/swap.img none swap sw 0 0' | sudo tee -a /etc/fstab
# 6. Verify
sudo swapon --showAlternatively, for a more durable fix, reduce paozhu's memory footprint by lowering the worker pool size and queue buffers in server.conf, or add physical RAM to the host.
Miscellaneous FAQ
How do I start a clean project without all the admin demo?
Run the built-in scaffolding script:
git clone https://github.com/hggq/paozhu.git myproject
cd myproject
sh mini_project.sh
# optional: for TechEmpower benchmark mode
sh mini_project.sh --benchmarkWhich platforms are officially supported?
Linux (Ubuntu ≥ 22.04, Rocky/AlmaLinux ≥ 9), macOS (Sequoia ≥ 15), Windows (vcpkg or xmake). Production deployments run primarily on Linux.
What license is Paozhu released under?
Where can I get help?
Open an issue on GitHub, or join the QQ group 668296235. Bug reports that include the exact cmake flags, OS version, and log/ excerpts get the fastest attention.