Overview
The WebUI provides a web-based management interface for NapCat, allowing you to configure settings, view logs, manage your bot, and monitor status. The WebUI configuration file (webui.json) controls access, authentication, and appearance settings.
Configuration File Location
Configuration Schema
Server Settings
Host address to bind the WebUI server.
::- Listen on all IPv4 and IPv6 interfaces127.0.0.1- Only accept local connections0.0.0.0- Listen on all IPv4 interfaces
Port number for the WebUI server. The WebUI will automatically try the next port if this one is occupied.
Completely disable the WebUI server. Useful for headless deployments where the WebUI is not needed.
Authentication
Authentication token for accessing the WebUI.
- On first run, a random 12-character token is automatically generated
- If set to the default value
napcat, it will be replaced with a secure random token - Can be overridden by the
NAPCAT_WEBUI_SECRET_KEYenvironment variable
Maximum number of login attempts allowed within a time window. Helps prevent brute-force attacks.
Access Control
Network access control mode:
none- No IP-based restrictions (default)whitelist- Only allow IPs in the whitelistblacklist- Block IPs in the blacklist
List of IP addresses or CIDR ranges allowed to access the WebUI when
accessControlMode is set to whitelist.Example: ["192.168.1.100", "10.0.0.0/8"]List of IP addresses or CIDR ranges blocked from accessing the WebUI when
accessControlMode is set to blacklist.Example: ["203.0.113.0/24", "198.51.100.50"]Enable reading the real client IP from the
X-Forwarded-For header.Enable this when the WebUI is behind a reverse proxy (nginx, Apache, etc.).Security Warning: Only enable this if you trust your proxy. Attackers can spoof this header if not properly configured.Auto-Login Settings
QQ account number to automatically log in on startup. Leave empty to disable auto-login.Can be combined with environment variables:
NAPCAT_QUICK_ACCOUNT- Account to auto-loginNAPCAT_QUICK_PASSWORD- Password for auto-login (will be MD5 hashed)NAPCAT_QUICK_PASSWORD_MD5- Pre-computed MD5 hash of password
Appearance
Custom theme settings for the WebUI including colors and fonts.
Configuration Examples
Accessing the WebUI
After starting NapCat, the WebUI URL will be displayed in the console:Authentication Methods
Method 1: Query Parameter (Recommended for first access)- Navigate to
http://127.0.0.1:6099/webui - Enter the token from the configuration file
- Click login
Changing the Token
You can change the WebUI token through:-
Environment Variable (highest priority):
-
Configuration File:
Edit
config/webui.jsonand update thetokenfield, then restart NapCat. - Through WebUI: Once logged in, navigate to Settings → Security → Change Token.
Environment Variables
The following environment variables override configuration file settings:Override the WebUI authentication token.
Preferred port for the WebUI. If unavailable, falls back to the configured port.
QQ account for auto-login (overrides
autoLoginAccount).Password for auto-login (will be MD5 hashed automatically).
Pre-computed MD5 hash of the password for auto-login.
SSL/HTTPS Support
To enable HTTPS for the WebUI:-
Place your SSL certificate files in the config directory:
cert.pem- Certificate filekey.pem- Private key file
- NapCat will automatically detect these files and enable HTTPS mode.
-
Access the WebUI using
https://instead ofhttp://:
Security Best Practices
- Use Strong Tokens: Generate a random, long token (at least 32 characters)
- Enable Access Control: Use IP whitelist in production environments
- Use HTTPS: Enable SSL certificates for encrypted connections
- Limit Login Attempts: Keep
loginRateat a reasonable value (5-10) - Restrict Host: Use
127.0.0.1if only local access is needed - Reverse Proxy: Put the WebUI behind nginx or Apache with proper security headers
Troubleshooting
Port Already in Use
If the configured port is occupied, NapCat will automatically try the next available port (up to 100 attempts). Check the console output for the actual port being used.Can’t Access WebUI
- Check if
disableWebUIis set tofalse - Verify the
hostsetting allows connections from your IP - Check firewall rules and network connectivity
- Review access control settings (
accessControlMode, whitelist/blacklist)
Token Not Working
The token used for authentication is the one stored in memory when NapCat starts. If you manually editwebui.json while NapCat is running, the changes won’t take effect until restart. Use the WebUI’s token change feature for immediate effect.