I started getting this error when attempting to debug a Static Web App, running behind the SWA CLI, with Visual Studio 2022. It had been working previously, so it's likely that some unknown update was responsible for the change in behaviour, but after hours of trying and failing to find the cause I hit upon this workaround.
In my case, the app's launchSettings.json
had both a launchUrl
and an applicationUrl
setting:
"launchUrl": "http://localhost:4280",
"applicationUrl": "http://localhost:5080"
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
In this case, the {url.port}
placeholder in the inspectUri
setting was expanding to the port specified in the launchUrl
setting, i.e. 4280 - the port the SWA CLI was running on. Examining the visualstudio-js-debugger.txt
file showed that this request was being refused. Changing it to explicitly use the port that the app was running on, i.e. 5080, fixed the problem for me.
"inspectUri": "{wsProtocol}://{url.hostname}:5080/_framework/debug/ws-proxy?browser={browserInspectUri}"