Mailhog Not Starting on a Single Local Site

Today I ran across the fact that one of my Local sites is not starting Mailhog at all. On other sites I can open Mailhog just fine, but on this one site when I click the Open MailHog button my browser just gives me this error:

localhost sent an invalid response.

ERR_INVALID_HTTP_RESPONSE.

Starting and stopping the site doesn’t fix this, nor does quitting all of Local and restarting it. Looking in Activity Monitor I can see that a search for mailhog comes up blank when this site is running, but will show a process when other sites are running. I’m using the Apple Silicon-native build, however I know that Mailhog itself is still Intel for the time being.

For the time being a semi-working workaround is to install an Email Log plugin to see the emails within WP, but with Mailhog broken the return value of wp_mail() is false, which is an awkward and not always working place to be in.

Any ideas why my Mailhog has ceased to start up on just one of my dozen or so Local sites or how to remedy this issue? Logs attached below…

Hi @alexclst

Checking out both of your logs and seeing a lot of errors that could indicate a port conflict. Something like antivirus, firewall, or other developer applications could have been blocking Local.

You can find more details about this and troubleshooting it here:

Hm, that does seem likely since such a warning is shown, but the site itself still works as I’d expect in a browser so I’d ignored that. But the output of the command that the help document you link to says to run when given the port Mailhog seems to reference when I click its button in Local (http://localhost:10075/) is referring to MySQL included in Local:

alex ~ ▶ sudo lsof -i:10075; sudo lsof -tnP -i:10075 | xargs -n 1 ps -p
COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
mysqld  83323 alex   29u  IPv4 0x6cee1edf9ac35643      0t0  TCP localhost:10075 (LISTEN)
mysqld  83323 alex   31u  IPv6 0x6cee1edfa14cc34b      0t0  TCP localhost:10075 (LISTEN)
  PID TTY           TIME CMD
83323 ??         0:02.21 /Applications/Local.app/Contents/Resources/extraResour

This seems a bit odd as everything about this Local site is just fine, except Mailhog. That is why I’d been ignoring the port warning, since it was functioning normally, except evidently for Mailhog. In fact, switching to localhost didn’t fix this issue for me at all when I just tried it, so I’ve switched back to the site domains mode I prefer.

So this does not seem to be a case where some external software has taken control of the port in question like that help document seems to assume, but rather that something in Local has gotten confused about what ports to use. Indeed, thinking along those lines, I looked in my sites.json file in my Library and discovered that the site in question (bDWLWGyj2) has an empty ports array, where other sites (such as JNstzH5Yf) list ports for HTTP, MailHog (SMTP and WEB) and MySQL… This is weird, right? How can I fix this problem, which now seems more like some bug in Local caused it? Do I just need to export and re-import the site and it will regenerate new ports and all? But before I do that, since I do have a WP plugin as a workaround, I’d like to help try to determine what caused this, if possible, so others don’t run into it.

Hello, I had a similar problem and published the solution here:

Regards

My sites in question have completely empty port elements in the JSON file. So I’d rather hear from Local developers why that may be, and how to fix that, or even help them debug what may have happened to me, than guess at what elements and port numbers to use blind.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.