Connect to Local's MySQL server from Windows WSL2

Issue Summary

Answer: WP-CLI (WSL2 Ubuntu) Can’t connect to Local’s MySQL server.

System Details

  • Which version of Local is being used?
    Answer: 5.9.7+5156

  • What Operating System (OS) and OS version is being used?
    Answer: Windows 10.

Details: WP-CLI on WSL (Ubuntu) connected to Local’s MySQL server as expected. The .yml file defines the Host (and Port), Username and Password that’s listed in Local’s database panel.

On upgrading to WSL2, wp db fails with the error:
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘’. I also tried ‘localhost’ in the .yml file with the same error.

The only difference is upgrading from WSL (no error) to WSL2 (error). Can anyone point me in the right direction? Thank you.

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