I got this error on a multisite install I was working on. It made no sense, and found some different solutions online, but eventually found a slightly different one related to my specific problem.
The fix was simple. Comment out this line:
#define( 'SUBDOMAIN_INSTALL', true );
What’s going on was simple: I had subdomains on my multisite WordPress installation, and I’d gotten rid of all the subdomain hosts.
Somewhere deep in the bowels of WP, a conditional was checking for a subdomain installation, and, based on that, bypassing using HTTP_HOST to set the cookie domain. Instead, it set the domain to the main site’s domain name.
I’m not sure I have this explanation correct, because the WP code is so twisty and turny. A function like get_site may call other functions that have layers of logic to check the values of constants, variables, and other things, before returning a value.
It’s particularly difficult with something like figuring out “what site are we looking at?” because there’s many global variables used in WordPress.