question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot Connect to local debugger after update

See original GitHub issue

Environment

System:
    OS: macOS 10.15.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 645.39 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 10.17.0 - /usr/local/opt/node@10/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/opt/node@10/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.8.4 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.4/11E146 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_232 - /usr/bin/javac
    Python: 2.7.16 - /usr/local/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1
    react-native: 0.62.2 => 0.62.2
  npmGlobalPackages:
    *react-native*: Not Found

Upgrading version

Went from 0.61.5 => 0.62.0 Then as i’ve been debugging and trying to get everything working i’ve now updated to 0.62.2

Description

React Native has been quite smooth for me, everything has been working since the project started until now, the first React Native upgrade for me. Since then i’ve lost the ability to run on a device and this is crucial to me since the app i’m building is using BLE which is not available in the simulator.

When running on device i get this messsage:

Connection to http://localhost:8081/debugger-proxy?role=client timed out. Are you running node proxy? If you are running on the device, check if you have the right IP address in RCTWebSocketExecutor.m.

To debug this issue i’ve tested the following

  • Validate the that the IP outputted during the build phase in xCode under Project => Report navigatior => build. According to this https://reactnative.dev/docs/running-on-device#connecting-to-the-development-server (where the issue i have is highlighted in the docs) the IP should be suffixed by xip.io, but it isn’t in my case, is this just outdated documentation? Or a bug? Or something that is invalid in my configuration?

  • Tried multiple networks / changed DNS servers, (including trying it when running a personal hotspot from my iPhone)

To give some more details i’ve followed the this page https://react-native-community.github.io/upgrade-helper/ to update the project. After this i’ve also ran updates via the react native CLI.

For even more context i’ve noticed some strange behaviour from the after running react native start where if i press r in my terminal one time the bundler opens multiple chrome tabs with the debugger UI

[[ Here i press R one time]]
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...
info Launching Dev Tools...

Furthermore, when running in the simulator instead i get this now: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:8081/debugger-ui/null' failed to load.

I’ve been at this for about 10 days now, very close to giving up. (really glad that i’m in a separate branch right now). Hopefully someone here can point me in the right direction as I’m quite new to native development

Reproducible demo

N/A

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:8
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dembe1commented, Apr 26, 2020

Some context I have had the same issue after upgrading from 0.59.10 to 0.62.2. Funnily enough, doing some research on this brought me back to a comment I wrote a year ago about a similar problem with the same root cause.

Your issue comes down to the device trying to access the Metro packager at http://localhost:8081/debugger-proxy?role=client, but localhost (from the view of the device) would be the device itself, whereas the packager is still running on your MacBook. You need to make sure that the iPhone uses the (local) IP address of your MacBook instead of localhost. The post mentioned above suggests a fix for this very issue, but it seems that the internals have changed so that the fix doesn’t work anymore.

The fix I was able to fix the issue by using the Configure Bundler option of the developer menu (you can open the developer menu by shaking the device) and putting in my MacBook’s local IP address (port should remain 8081, if you haven’t somehow changed the port the packager is running on).

Optional: If your packager isn’t started at all In fact, in my case, I had an additional issue that needed to be fixed in order for things to work. The packager was not started at all when I tried to run on a device from Xcode. If you also encounter this (i.e. the packager window doesn’t pop up when running from Xcode), I can recommend this fix, it worked for me.

0reactions
jamiedaycommented, Jul 8, 2020

@dembe1 Works for me - but it is just a workaround, is it not?

At least for me I have to Configure Bundler to link to Metro every time I rerun the app. The app doesn’t start up configured properly as it’s supposed to.

I suspect something wrong in the Bundle React Native code and images build phase.

EDIT: My problem was fully solved here https://github.com/react-native-community/upgrade-support/issues/25#issuecomment-655245024

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to Connect to the Microsoft Visual Studio Remote ...
Learn the meaning of "Unable to Connect to the Microsoft Visual Studio Remote Debugging Monitor", the possible causes, and the solutions.
Read more >
Cannot connect debugger after update 03/06/2018
Project is successfully build, deployed, and app is being started (on simulator) but after 1-2 seconds stops. error MT1006: Could not install ...
Read more >
Unable to connect with remote debugger - Stack Overflow
Press Cmd + M on emulator screen · Go to Dev settings > Debug server host & port for device · Set localhost:8081...
Read more >
Troubleshooting common PHP debugging issues | PhpStorm ...
When the debugger cannot connect or refuses the connection, check the following: Make sure Xdebug or Zend Debugger are configured to connect ......
Read more >
Unable to debug with remote Python interpreter - YouTrack
Unable to debug with remote Python interpreter: cannot connect to X server ... PY-23345 matplotlib support not working after installation of update.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found