The following steps worked for me:
Run the following command inside WSL to check if VS Code is installed:
code --version
If this gives an error, install VS Code Server inside WSL:
wget -qO- https://aka.ms/install-vscode-server/setup.sh | bash
If VS Code is installed but still not working, try reinstalling the remote:
rm -rf ~/.vscode-server
rm -rf ~/.vscode
code .