When WHMCS shows "License Invalid" and won't let you into the Admin Area, you can still find out why. Put a small script next to init.php, run the license check yourself and print its debug log. The log shows what actually went wrong between your server and the WHMCS licensing server.
The error screen itself only tells you that the check failed. Not whether the key is wrong, the IP changed after a move, or the server can't reach the licensing server at all. The usual places to look, the Activity Log and the module debug log, are inside the Admin Area. The same Admin Area the error keeps you out of.
debug_license.php: print the raw license log #
Create debug_license.php in the root of your WHMCS installation, where init.php is:
<?php
require 'init.php';
/** @var \WHMCS\License $licensing */
$licensing = \DI::make("license");
echo '<pre>';
// Attempt to validate the license
var_dump($licensing->validate());
echo "\r\n";
// Output the raw debug log
var_dump($licensing->getDebugLog());
echo '</pre>';\DI::make("license") returns the \WHMCS\License object from the WHMCS container. validate() runs the check, and getDebugLog() returns everything the check wrote down on the way.
How to run it #
Open https://your-whmcs-domain.com/debug_license.php in a browser, or run php debug_license.php in a terminal from the WHMCS root. First you get true or false, then the raw log of the conversation with the licensing server. Look for connection errors, a refused connection, an IP or domain that doesn't match, or DNS that doesn't resolve.
Delete the file as soon as you're done. It sits in a public directory and prints details about your license to anyone who opens it.
What the log usually points to #
The WHMCS docs list the same few causes, and the log tells you which one you have.
The key doesn't match. Compare the $license line in configuration.php with the key in the WHMCS Member Area under Services > My Licenses. An extra space, a line break or a stray quote is enough to break it.
You moved WHMCS to a new server or domain and didn't reissue the key. In the Member Area open Services > My Licenses, select the key and click Reissue. If the license came from your hosting provider, they have to reissue it. After a move to a different hosting provider you need a new key. Then put the new value into $license.
The server can't reach the licensing server. WHMCS calls this a "No Connection" error, and it's usually cURL or DNS. There's a built-in test for it: open /admin/login.php?conntest=1. A good result ends with "Response Code: 200" and "Connection Successful!". Anything else is a job for whoever runs the server: DNS for whmcs.com, outgoing HTTPS, the cURL extension.