DEV Community

Cover image for Connect MySQL Workbench to MySQL Server in WSL using Node
Susan Githaiga
Susan Githaiga

Posted on

Connect MySQL Workbench to MySQL Server in WSL using Node

Windows Subsystem for Linux(WSL) is a Microsoft Windows feature that lets you run a Linux environment directly on your Windows machine without needing a separate virtual machine or dual booting your PC.

WSL uses your window's system IP address as it's own. However, the default MySQL workbench config only accepts requests and connections from 127.0.0.1

If you want to connect your NodeJS app to MySQL workbench, then you need to use the ip address of your host machine(PC). To do this, follow these steps:

  • Open your WSL terminal.

  • Run the following command in your WSL terminal to retrieve your host machine's(PC's) IP address:

ip route show | grep -i default | awk '{ print $3}'

Image description

  • On your .env file, change the DB_HOST(the variable which stores your host IP Address) to your host machine's IP Address

Image description

Now, your NodeJS server is running and ready for use:

Image description

To learn more about how to access your PC's network applications through WSL, read the following article on Microsoft learn: Accessing network applications with WSL

Billboard image

Imagine monitoring that's actually built for developers

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitor creation and configuration with Monitoring as Code.

Start Monitoring

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay