Access host computer's localhost from website in Local (guest)

I have a Wordpress website running in local that needs to access an API that is running on the host computer at http://localhost:8081 — and I cannot figure out where to look for documentation. What kind of container is Local running the websites in?

Note: I’ve tried searching for “virtualbox access host localhost” or “docker access host machine localhost” and have tried the suggestions on those pages without success. Perhaps that’s not what Local is using?

I appreciate any help or direction. Thanks!

Update on this one: if you need to access a host machine’s localhost then use use VirtualBox’s special ip address, and make sure the network settings for the VirtualBox Local by Flywheel image are set to NAT — and then restart Local to apply.

1 Like

@creativeculture, thanks for the info! It would certainly be interesting to see how this changes without VirtualBox as part of the environment. The newest versions of Local have stripped VB away.

@mattwhosthat I think it makes this information irrelevant, which is great! Since the website isn’t running in VB, it can access localhost as normal. I’ve been using the new lighting and it works as expected. Thanks!

Another solution I found was updating the /etc/hosts files of your Local VM and then also your localhost.

If you setup you localhost (not Local VM) machine’s etc/hosts file with something like: and then add to the Local VM’s /etc/hosts file, then you can access from your Local wp machine.

Thanks for the tip about the address, too! I was having a really hard time tracking down this issue!