How can I use GraphQl PLayground on a GraphqL Server running in WSl2 Ubuntu?

  apollo, graphql, windows, wsl-2

I have a graphql ApolloServer running locally using serverless on Windows 11 inside WSL2 Ubuntu.

When I open the url it gives, it shows the Apollo Page asking me if I want to query my server. The url, is http://localhost:4500/local/graphql.

The issue starts when I go to the playground and it seems it cant connect – there are no errors on console, no messages, nothing. I tried using the diagnostic tool they provide on the messages, but it just hangs up when using.

I read that it might be because localhost is not accessible from outside windows or something.

The cherry on top is that it works flawlessly if I run it on a Macbook. So the code is not the issue.

Do I need to forward ports for WSL2? I thought that was done automagically by the system to be accessible, but I cant seem to figure out. Any thoughts on what I can look into ?

Source: Windows Questions