Prerequisites
Before installing the ZKTeco Biometric Server, ensure you have:- Python 3.7 or higher installed on your system
- Network access to your ZKTeco biometric devices
- Device IP addresses and connection details
- pip package manager (usually comes with Python)
Check your Python version with:
python --version or python3 --versionInstallation Steps
Clone or Download the Repository
Get the source code for the server:Or download and extract the source files manually.
Install Python Dependencies
The server requires the following Python packages:
Install all dependencies at once:Or install individually:
| Package | Version | Purpose |
|---|---|---|
| flask | ≥2.3.0 | Web framework for REST API |
| pyzk | ≥0.9 | ZKTeco device communication library |
| pyopenssl | ≥23.0.0 | SSL/TLS certificate generation |
| requests | ≥2.31.0 | HTTP client library |
| psycopg2-binary | latest | PostgreSQL database adapter |
Verify Installation
Check that all packages are installed correctly:If this command runs without errors, you’re ready to proceed.
Configure Environment Variables
The server can be configured using environment variables. Create a
.env file or set them in your shell:Single Device Mode (servidor.py)
Multi-Device Mode (server.py)
In multi-device mode, devices are managed via API endpoints rather than environment variables. The server will create a default device on first run.
SSL Certificate Setup
The server automatically generates self-signed SSL certificates on first run. This process happens automatically when you start the server.
Automatic Generation
Ifpyopenssl is installed and no certificates exist, the server will:- Generate a 2048-bit RSA key pair
- Create a self-signed X.509 certificate
- Save
cert.pemandkey.pemin the working directory - Certificate is valid for 365 days
Using Custom Certificates
For production environments, use certificates from a trusted Certificate Authority:- Obtain your SSL certificate and private key
- Save them as
cert.pemandkey.pem(or configure custom paths) - Update environment variables if using custom paths:
HTTP Fallback
Ifpyopenssl is not installed or certificate generation fails, the server will run in HTTP mode:Network Configuration
Ensure network connectivity between the server and biometric devices:
Test Device Connectivity
Firewall Rules
Make sure the following ports are open:- 4370: ZKTeco device communication port (TCP/UDP)
- 5000: Server API port (or your configured API_PORT)
Device Configuration
On your ZKTeco device:- Ensure network settings are configured correctly
- Note the device IP address
- Verify the device password (default is usually 0)
- Enable network communication features
Start the Server
Launch the server using one of the implementations:The server is now running and ready to accept requests!
Successful Startup
You should see output similar to:Verify Installation
Test the server with a simple health check:Expected response:If the device is reachable, you’ll receive connection details and device information.
Test Device Connection
Running as a Service
Linux (systemd)
Create a systemd service file/etc/systemd/system/zkteco-server.service:
Windows (NSSM)
Use NSSM (Non-Sucking Service Manager) to run as a Windows service:Troubleshooting
Connection Errors
Cannot connect to device
Cannot connect to device
- Verify the device IP address and port
- Check network connectivity with
ping - Ensure firewall rules allow traffic on port 4370
- Verify the device password is correct
SSL Certificate Errors
SSL Certificate Errors
- Use the
-kflag with curl to skip verification:curl -k https://... - Install your certificate in the system trust store
- Or configure your client to trust the self-signed certificate
Import Errors
Import Errors
- Reinstall the problematic package:
pip install --force-reinstall <package> - Check Python version compatibility
- Try using a virtual environment to isolate dependencies
Permission Errors
Permission Errors
- Ensure the server has write permissions for certificate files
- Check permissions for
devices.jsonin multi-device mode - Run with appropriate user privileges (avoid running as root)
Next Steps
Quickstart Guide
Get started with basic operations in 5 minutes
API Reference
Explore all available endpoints
Device Management
Configure and manage multiple devices
Configuration
Advanced configuration options