When connected on Wifi:
PS C:\Users\Julio> Invoke-RestMethod juliobs.com
Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a receive.
At line:1 char:1
+ Invoke-RestMethod juliobs.com
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
When connected on Cable:
PS C:\Users\Julio> Invoke-RestMethod juliobs.com
<!DOCTYPE html>
<!-- Last Published: April 6, 2023 --><html lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
...
Both connections are to the same router using the same DNS config.
curl
from cmd.exe
or WSL
work fine on wifi.
The same error happened in one other Wifi network.
Tested with PowerShell 5.1 (on Windows Terminal 1.16 and Windows PowerShell ISE)
PS C:\Users\Julio> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 22621 963
The error "The underlying connection was closed" is usually related to TLS, but this does not seem to be the case here.