Azure Website Debugging: The network connection to *.azurewebsites.net:4020 has been lost. Debugging will be aborted.
Recently my colleagues and I created a lot of SharePoint provider-hosted addins – in our case that is just a MVC Website hosted on Azure that talks balk to SharePoint. And I have to say it is good fun because we could actually debug a production site/business application in case something unforeseeable happens (aka. bugs). And the integration in Visual Studio via the Cloud Explorer could not be simpler. Right click on the website, attach debugger and see the problem.
That worked a long time perfectly for us – but something changed and Visual Studio 2015 dropped the connection once a breakpoint is hit (sometimes even earlier). Strangely debugging still worked with Visual Studio 2013.
Attaching with a Visual Studio 2015 Debugger either from Cloud Explorer, Server Explorer or directly via “attach to process” attaches the debugger briefly (if at all) and then results in two errors:
- The web browser shows: 502 – Web server received an invalid response while acting as a gateway or proxy
- In Visual Studio 2015 an error box shows: The network connection to <>.azurewebsite.net:4020 has been lost. Debugging will be aborted.
The fix is rather simple. In Visual Studio open Debug menu from the top and click on Options:
After that, Debugging worked like a charm again.
I did not find that one out myself – the awesome Microsoft Support (I am looking at you Akash Khandelwal!) spent hours troubleshooting my problem. He early noticed that there is a something with WPF in the logs but we initially ruled that one out. After a while his team suggested to disable this option – and it worked!
During the debugging session I learned a lot about Azure Website troubleshooting – great stuff!
Max’s free time is spent on twitter (@maxmelcher) mostly with a good coffee in his hands.
Latest posts by Max Melcher (see all)
- 3x Office 365 Developer Bootcamps: Munich, Berlin and Hamburg! - October 3, 2017
- PowerShell: Upload a CSV file to a SharePoint List - September 11, 2017
- How about building a magic mirror?! - March 25, 2017