Can't run services, get launchctl enable gui/501 error

I just restarted my server, and I’m completely dead in the water. It’s a very new, very clean install, but now when I try to run a service I get errors like:

Error: Failure while executing; /bin/launchctl enable gui/501/homebrew.mxcl.mysql exited with 64.

I am running headless, and I’m running services with no gui. Up until my last reboot of the machine I could execute all the brew service... commands successfully.

I see articles like this homebrew issue and others that reference it, but there is no actionable information in any of those posts.

If I use sudo brew services start php I can get it to run, but no way should I have to elevate the privileges for that process. That’s begging for trouble. The same elevation does not get mysql running in any case.

I tried logging in remotely just to create a gui session when I issued the commands, but without success.

I know Apple changed stuff a couple of years ago, and probably hasn’t stopped changing stuff, but running headless is a fundamental requirement I expect my far-wiser-than-me package manager wizards to solve.

Are there alternate commands I could issue directly to launchctl that would overcome this problem? Even if through some hand-wavery I get this thing back up and running tonight, what is the proper way to start services on a headless machine now?

Check your system logs to see what’s happening. Nothing in homebrew requires a GUI.