How to Fix “Unauthorized API Host” Error When Connecting WISECP or WHMCS to CWP

0 11 hours ago

Trying to connect your WHMCS or WISECP billing panel to a CWP (Control Web Panel) server and running into this error?

bashCopyEditConnection test failed. API: unauthorized host

This is a common issue when using CWP’s API for automated account creation and management — but thankfully, the fix is simple once you understand what’s causing it.


🚫 What Causes the “Unauthorized Host” Error?

CWP’s API checks that the incoming request comes from an approved IP address — known as the “IP Origin”. If your WISECP server’s IP isn’t explicitly listed in CWP, it will reject the request with this error.

Even if you’ve whitelisted the IP in CSF (ConfigServer Firewall), that does not grant API access.


✅ How to Fix It

🔹 Step 1: Find Your WISECP Server’s Public IP

Run this command on your WISECP server:

bashCopyEditcurl https://ifconfig.me

Copy the IP it returns — e.g.:

1.1.1.1

🔹 Step 2: Add the IP to CWP’s API Configuration

On your CWP server, open the API key file:

nano /root/.conf/api_key.conf

Add this line (or update if it exists):

your_api_key_here|192.250.232.15

Replace your_api_key_here with a secure key you’ll use in WISECP.

✅ Save the file and exit.


🔹 Step 3: Restart the API Service

Run:

sh /scripts/restart_cwpsrv

This reloads the API system with your new configuration.


🔹 Step 4: Configure WISECP to Use the API

In WISECP admin panel:

  • API URL:
    https://your-cwp-ip:2304/v1/
    (✔ Don’t forget the trailing / and use HTTPS if enabled)
  • API Key:
    The key you set in api_key.conf
  • Secure SSL:
    ✅ Enable it if your server is using HTTPS on port 2304
  • Server IP:
    Your CWP server’s public IP

Click Test Connection — it should now succeed.


⚠️ Bonus Fix (Strange But True)

If the IP setup above still fails, some users have solved it by entering by% in the “IP Origin” field inside CWP’s API web interface.

While not officially documented, it works because CWP may interpret it as a wildcard (like SQL LIKE 'by%'). Still, this is more of a workaround than a best practice.


🚀 Need High-Performance VPS for CWP + WISECP?

Make sure your panel automation runs fast and reliably — even with traffic spikes.

👉 Explore high-performance VPS and dedicated servers on Servers9 — optimized for CWP, firewalls, and billing panels like WISECP.


💬 Need Help Setting It Up?

If you’d rather let experts handle it:

📨 Contact Servers9 Support — they can connect WISECP to your CWP server in minutes.