Safari Web inspector keeps disconnecting

user2727195 picture user2727195 · Jul 6, 2015 · Viewed 26.4k times · Source

I've Safari 8.0.6 with iOS 8.3 on my iPad, while debugging through Web Inspector on my Mac (10.10.3), the connection keeps on disconnecting (I don't see the device name under Develop menu upon disconnection) but can resume if I quit safari followed by a relaunch then I'm able to refresh and inspect remotely again.

Answer

Stefan Rein picture Stefan Rein · Mar 28, 2018

There are a few things to try:

1. Test on the Xcode Simulator:

Open the iPhone simulator in Xcode and debug there with Safari Web Inspector.

Sidenote: Maybe you need to download the Safari Technology Preview

2. Reset your location and privacy settings on your device.

Settings > General > Reset > Reset Location & Privacy

3. Debugging on a real device

With this configuration it seems to work right now.

iPhone X, iOS Version 12.1.3 macOS Mojave Version 10.14.2 (18C54) Safari Version 12.0.2 (14606.3.4)

Edit 2019.08.13

Settings -> Safari -> Advanced -> Check that Webinformation is toggled on.

It was suddenly toggled off and I couldn't connect via the Web Inspector. After toggling it on, it worked.

For other devices / versions, please read further down (Maybe you can decrease your build size).


EDIT: 2018.09.20

@Chet found out, the Web Inspector keeps disconnecting for too large JS files and map files

https://stackoverflow.com/a/52338231/4641479

Issue on Github:

https://github.com/google/ios-webkit-debug-proxy/issues/275

https://github.com/google/ios-webkit-debug-proxy/issues/274

I could confirm this on a real device with a production build (1.8 MB + 2.4 MB files), the Safari Web Inspector stays always connected.

enter image description here

Since for the development build it is not:

enter image description here


Before my web inspector very rarely worked and often just stopped working - but was still open. After the safari update the web inspector opens and closes immediately. If you encounter such problems..

This will work:

Step 1. Get the latest Safari Browser

Safari: 11.1 (12605.1.33.1.2)

https://developer.apple.com/safari/download

macOS Sierra and OS X El Capitan (I assume macOS high Sierra is also supported)

Maybe you need to download the Safari Technology Preview


Step 2. Reset your location and privacy settings

On your device go to:

Settings > General > Reset > Reset Location & Privacy

Source: https://forums.developer.apple.com/thread/87181


Step 3. Connect your device

Open Safari on OS X If you had connected your iPhone device with an usb cable, disconnect it first. Now plug it in.

On OS X Safari go to:

Develop > Device name > Apply for development

Now on your phone there is a permission question. Choose trust and now you can choose the open tab on your devices safari and debug.


Happy debug!

Now the web inspector stays connected.