Local Express server refuses Dgraph (docker) GET request

I’ve finally resolved it. Apparently, WSL 2 doesn’t expose the network of the distro to the host computer which is why I cannot connect to the node server. What I did was to use the IPv4 address of the computer to map the custom HTTP request URL. This solution was found on:

WSL2 cannot connect to localhost when the service is running on Windows · Issue #5211 · microsoft/WSL (github.com)

Changes to the mutation became (assuming IPv4 address of the host computer is 192.168.0.1):

Fetch: Fetching
    @custom(http: { url: "http://192.168.0.1:4000/try", method: "GET" })

However, it would be much appreciated if you can provide me with some other details to mapping the WSL 2 ports onto the host computer. Thanks once again!

Edit
I also needed to expose the IPv4 of the virtual machine to the host through netsh. The solution to that can be found here:

WSL Port Forwarding - DEV Community

2 Likes