WSL2 Connection Issues, Timeouts and Unable to Open Stream and Network Unreachable

1: Try running your composer commands with sail if you using laravel and docker.
example : sail composer require laracasts/generators --dev

2: Second try running

wsl --shutdown
wsl ping google.com -c 4

3: Third try the below power shell command

# Check these threads before proceeding:
# https://github.com/microsoft/WSL/discussions/5857
# https://github.com/microsoft/WSL/issues/5821
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
  $CmdLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
  Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CmdLine
  Exit
}
# Restart the Host Network Service 
Restart-Service -Force -Name hns
# Restart the Windows Subsystem for Linux Manager
Restart-Service LxssManager
# Restart the WSL Network adapter
Restart-NetAdapter -Name "vEthernet (WSL)"

Article 1

https://gist.github.com/danvy/9486bf730371436131cb888ff4c2ceb6

Article 2

https://github.com/microsoft/WSL/issues/5821

Flutter Display Name

Inside your pubpec.yml add the below

Dev Dependency add
flutter_launcher_name: "^0.0.1"

Then to set your name add
flutter_launcher_name:
name: "E-Centive"

dev_dependencies:
  flutter_launcher_name: "^0.0.1"
  
flutter_launcher_name:
  name: "E-Centive"

Flutter Setup

Step 1:
- Create a folder in your C drive called Flutter
- Download Flutter SDK and copy it into your Flutter folder
- Download Flutter here -> https://flutter.dev/docs/get-started/install/windows
- Extract Flutter into your folder. Then you remove the zip folder.

Step 2:
- Open your START MENU, and search "Edit Environment Variables For Your Account"
- Open it
- Assuming you copied your Flutter to C:\flutter
- In your environment Variables there is a Path option
- Edit Path and add a new variable and in there add the path to your Bin folder in Flutter
- C:\flutter\bin

Step 3:
- During install ensure you select Android SDK and HAXM and Android Virtual Device
- Download and Install Android Studio
- https://developer.android.com/studio

Step 4:
- Open your CMD or Power Shell and run "flutter doctor"
- If you get and ERROR for "Android licenses not accepted"
-- Run "flutter doctor --android-licenses"
-- Accept the licenses and run flutter doctor again to check

Step 5:
- Download and Install Java JDK
- https://www.oracle.com/java/technologies/javase-jdk16-downloads.html
- Open your START MENU, and search "Edit Environment Variables For Your Account"
- Now you are just going to add a new Variable
- Create a Folder in your C drive called Java
- Set you Variable Name to "JAVA_HOME"
- Set your Variable Value to "C:\Java\jdk-16.0.1" (Your Variable Value is the path to your Java JDK)

Step 6:
- In your C drive create a folder "flutter_projects"
- Open your C:\flutter_projects in CMD or Power Shell

(READ -> naming convention in flutter, all lower case and no spaces and no dashes)
- Run "flutter create project_name"

Step 7:
- Open your project in Android Studio. You will see an android icon when you search for it. Just open the folder for that project.
- You should be prompted for a flutter plugin. Accept and install the flutter plugin and then you can minimize your Android Studio.

Step 8:
- Open Visual Studio Code and install the Flutter and Dart Plugins
- You can find them by searching your packages with " publisher:"Dart Code" "