can t connect to Metro Bundler

Please provide the following:

  1. SDK Version: i don t know how to see that
  2. Platforms(Android/iOS/web/all): ios

Hello,

The connection with Metro Bundler is failing (that what is writing…). I need to try 10 times each time i want to start expo, and only if i am lucky i can open it.
the err message is:

Could not get status from Metro bundler. connect ECONNREFUSED 127.0.0.1:19001
Connecting to Metro bundler failed.
Error: Connecting to Metro bundler failed.
    at _waitForRunningAsync (/@expo/xdl@57.4.6/src/Project.ts:1630:11)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)

i had install npm, update npm, i do eachTime rm -rf .expo . Sometime it works, but 80% of the try it doesn t work.

If someone have a solution it would be great. Thank you.

Hi

What version of expo-cli are you running? Run expo --version (but “xdl@57.4.6” seems to imply you’re running the latest version of expo-cli.)

Does this error happen after about 30 seconds? If not, how long does it take from running expo start to getting this error?

The code seems to try 300 times, waiting 100ms between attempts and Metro should be able to start within 30 seconds.

Does it print out something like the following before you get the error?

Starting Metro Bundler on port 19001.

If so, are you able to see it running between when it prints the above and when you get the error:

ps ax | grep 19001

You should see a node process running that looks similar to this:

29902 pts/28   Sl+    0:03 /usr/local/bin/node /path/to/app/node_modules/react-native/local-cli/cli.js start --port 19001 --customLogReporterPath /usr/local/lib/node_modules/expo-cli/node_modules/@expo/xdl/build/reporter/index.js --sourceExts expo.ts,expo.tsx,expo.js,expo.jsx,ts,tsx,js,jsx,json,wasm --assetPlugins /path/to/app/node_modules/expo/tools/hashAssetFiles.js

version: 3.11.7

after: expo start , i got that

jerome@jeromes-MacBook-Pro rn-tp1 % EXPO_DEBUG=true expo start
Starting project at /Users/jerome/Documents/reactNative/rn-tp1
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)

most of the time, it stay like it… so after 5-10mn i stop it (ctrl C)

if it run by itself (before i stop it), i get that

Could not get status from Metro bundler. connect ECONNREFUSED 127.0.0.1:19001
Connecting to Metro bundler failed.
Error: Connecting to Metro bundler failed.
    at _waitForRunningAsync (/@expo/xdl@57.4.6/src/Project.ts:1630:11)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)

Nothing else pop up.

And when it works, i got this

debug Checking for a newer version of React Native
debug Current version: 0.61.4
debug No release cache found
debug No release cache found
debug Checking for newer releases on GitHub
debug No release cache found
watchman warning:  opendir(/Users/jerome/Documents/mongoDb/db/diagnostic.data) -> Permission denied. Marking this portion of the tree deleted
To clear this warning, run:
`watchman watch-del /Users/jerome ; watchman watch-project /Users/jerome`


debug Saving W/"6d6386b01438c6ef0acd213d304b5839" to cache
debug No release cache found
debug No release cache found
debug Latest release: 0.60.0
opendir(/Users/jerome/Documents/mongoDb/db/diagnostic.data) -> Permission denied. Marking this portion of the tree deleted
To clear this warning, run:
`watchman watch-del /Users/jerome ; watchman watch-project /Users/jerome`


opendir(/Users/jerome/Documents/mongoDb/db/diagnostic.data) -> Permission denied. Marking this portion of the tree deleted
To clear this warning, run:
`watchman watch-del /Users/jerome ; watchman watch-project /Users/jerome`


Tunnel ready.

Weird. So it never prints “Starting Metro Bundler on port NNN.”?

I see from the code that when you set EXPO_DEBUG it should run Metro in verbose mode, so maybe that’s why you’re getting all the extra “debug” stuff, but strangely I’ve never seen that and it doesn’t happen if I run EXPO_DEBUG=true expo start.

Those watchman warnings are very strange. It doesn’t make sense that watchman would be trying to watch stuff outside of your project.

Try running:

watchman watch-del-all

Can you try checking if any node or watchman processes are running when you do not have expo start running? (There could be something unrelated to Expo, so don’t just kill them.)
If you do, and you know that they are related to expo, then try killing them.

Also remove anything related to react-native or haste from $TMPDIR.

Then try expo start again and see what you get.

watchman:

no, it never prints “ Starting Metro Bundler on port NNN.

There is my running connections (it’s more or less like it), before i run expo

jerome@jeromes-MacBook-Pro rn-tp1 % ps -ef | grep node        
  501   539   506   0 12:20PM ??         0:09.75 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) --type=renderer --disable-color-correct-rendering --field-trial-handle=1718379636,3891428239141244774,4493848427773569087,131072 --disable-features=LayoutNG,SpareRendererForSitePerProcess --lang=en-US --standard-schemes --secure-schemes=vscode-resource --bypasscsp-schemes --cors-schemes=vscode-resource --fetch-schemes=vscode-resource --service-worker-schemes --app-path=/Applications/Visual Studio Code.app/Contents/Resources/app --node-integration --no-sandbox --no-zygote --background-color=#fdf6e3 --disable-blink-features=Auxclick --num-raster-threads=2 --enable-zero-copy --enable-gpu-memory-buffer-compositor-resources --enable-main-frame-before-activation --service-request-channel-token=4850816716330009184 --renderer-client-id=6 --no-v8-untrusted-code-mitigations
  501  1073   506   0  3:32PM ??         0:10.42 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) --type=renderer --disable-color-correct-rendering --field-trial-handle=1718379636,3891428239141244774,4493848427773569087,131072 --disable-features=LayoutNG,SpareRendererForSitePerProcess --lang=en-US --standard-schemes --secure-schemes=vscode-resource --bypasscsp-schemes --cors-schemes=vscode-resource --fetch-schemes=vscode-resource --service-worker-schemes --app-path=/Applications/Visual Studio Code.app/Contents/Resources/app --node-integration --webview-tag --no-sandbox --no-zygote --background-color=#fdf6e3 --num-raster-threads=2 --enable-zero-copy --enable-gpu-memory-buffer-compositor-resources --enable-main-frame-before-activation --service-request-channel-token=12206910109130693500 --renderer-client-id=13 --no-v8-untrusted-code-mitigations
  501  1083  1077   0  3:32PM ??         0:00.65 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) --max-old-space-size=3072 /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js --syntaxOnly --useInferredProjectPerProjectRoot --disableAutomaticTypingAcquisition --cancellationPipeName /var/folders/ym/vp1pdmns0ksg1zl25y_txmyc0000gn/T/vscode-typescript501/62f632c8583eba51527e/tscancellation-7076b6befb2882a96a71.tmp* --globalPlugins typescript-tslint-plugin --pluginProbeLocations /Users/jerome/.vscode/extensions/ms-vscode.vscode-typescript-tslint-plugin-1.2.3 --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation
  501  1084  1077   0  3:32PM ??         0:09.52 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) --max-old-space-size=3072 /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /var/folders/ym/vp1pdmns0ksg1zl25y_txmyc0000gn/T/vscode-typescript501/62f632c8583eba51527e/tscancellation-576205b50fd87af76ab6.tmp* --globalPlugins typescript-tslint-plugin --pluginProbeLocations /Users/jerome/.vscode/extensions/ms-vscode.vscode-typescript-tslint-plugin-1.2.3 --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation
  501  1089  1084   0  3:32PM ??         0:03.84 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typingsInstaller.js --globalTypingsCacheLocation /Users/jerome/Library/Caches/typescript/3.7 --enableTelemetry --typesMapLocation /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typesMap.json --validateDefaultNpmLocation
  501  1124  1078   0  3:39PM ttys000    0:00.00 grep node

Also remove anything related to react-native or haste from $TMPDIR . : i’have done

npm cache clean --force

run ‘expo start’ (tryied 4 times). exactly same before, except that it doesn’t run with no err message. the err connection comes up after not more than 2mn. It shows up

jerome@jeromes-MacBook-Pro rn-tp1 % expo start
Starting project at /Users/jerome/Documents/reactNative/rn-tp1
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)

then

Could not get status from Metro bundler. connect ECONNREFUSED 127.0.0.1:19001
Connecting to Metro bundler failed.
Set EXPO_DEBUG=true in your env to view the stack trace.

if i run EXPO_DEBUG=true expo start, it shows (same as before)

jerome@jeromes-MacBook-Pro rn-tp1 % EXPO_DEBUG=true expo start
Starting project at /Users/jerome/Documents/reactNative/rn-tp1
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
Could not get status from Metro bundler. connect ECONNREFUSED 127.0.0.1:19001
Connecting to Metro bundler failed.
Error: Connecting to Metro bundler failed.
    at _waitForRunningAsync (/@expo/xdl@57.4.6/src/Project.ts:1630:11)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)

Where do you see that watchman config? Watchman should not be watching your whole home directory.

OK, so it doesn’t look like you have any Expo-related node processed hanging around while expo start is not running.

By this I mean:

cd $TMPDIR
ls

and then get rid of anything to do with React Native or haste.

When you run expo start, try expo start -c.

For some reason it seems that Metro is not starting, but I would have expected to see the “Starting Metro Bundler on port NNN.” message regardless of whether or not it starts correctly. Maybe I am missing something.

You might get more info if you try to run Metro manually. (This will not solve the problem. It might give us more insight into the problem, though.) Something like this:

cd my-app
APPDIR=$(pwd)
NPMROOT=$(npm root -g)
node "${APPDIR}/node_modules/react-native/local-cli/cli.js" start --port 19001 --customLogReporterPath "${NPMROOT}/expo-cli/node_modules/@expo/xdl/build/reporter/index.js" --sourceExts expo.ts,expo.tsx,expo.js,expo.jsx,ts,tsx,js,jsx,json,wasm --assetPlugins "${APPDIR}/node_modules/expo/tools/hashAssetFiles.js" --verbose --reset-cache

If it works it should print out something like this:

{"type":"initialize_started","port":19001,"projectRoots":["/Users/username/my-app"]}
{"type":"transform_cache_reset"}
{"type":"dep_graph_loading"}

Then you can press Ctrl-C to kill it.

Let us know what happens when you try running it manually.

I have done, in the terminal: watchman watch-del-all
(i probably installed watchman it at the wrong place… :worried:)

done, i had only one haste doc (the cpu didn’t like it, i had to restart it).

That what i get when i started manually (i mean, like you said), it stayed like it during 10mn then i cutted it off (ctrl c).

jerome@jeromes-MacBook-Pro rn-tp1 % APPDIR=$(pwd)
jerome@jeromes-MacBook-Pro rn-tp1 % NPMROOT=$(npm root -g)
jerome@jeromes-MacBook-Pro rn-tp1 % node "${APPDIR}/node_modules/react-native/local-cli/cli.js" start --port 19001 --customLogReporterPath "${NPMROOT}/expo-cli/node_modules/@expo/xdl/build/reporter/index.js" --sourceExts expo.ts,expo.tsx,expo.js,expo.jsx,ts,tsx,js,jsx,json,wasm --assetPlugins "${APPDIR}/node_modules/expo/tools/hashAssetFiles.js" --verbose --reset-cache
{"type":"initialize_started","port":19001,"projectRoots":["/Users/jerome/Documents/reactNative/rn-tp1"]}
{"type":"transform_cache_reset"}
{"type":"dep_graph_loading"}
debug Checking for a newer version of React Native
debug Current version: 0.61.4
debug No release cache found
debug No release cache found
debug Checking for newer releases on GitHub
debug No release cache found
debug Saving W/"6d6386b01438c6ef0acd213d304b5839" to cache
debug No release cache found
debug No release cache found
debug Latest release: 0.60.0

then after the ctrl -c, this poped up

watchman warning:  opendir(/Users/jerome/Documents/mongoDb/db/diagnostic.data) -> Permission denied. Marking this portion of the tree deleted
To clear this warning, run:
`watchman watch-del /Users/jerome ; watchman watch-project /Users/jerome`

opendir(/Users/jerome/Documents/mongoDb/db/diagnostic.data) -> Permission denied. Marking this portion of the tree deleted
To clear this warning, run:
`watchman watch-del /Users/jerome ; watchman watch-project /Users/jerome`

opendir(/Users/jerome/Documents/mongoDb/db/diagnostic.data) -> Permission denied. Marking this portion of the tree deleted
To clear this warning, run:
`watchman watch-del /Users/jerome ; watchman watch-project /Users/jerome`

{"type":"dep_graph_loaded"}

Then i tryied (4 times to start a project), twice with expo start -c and twice with expo start. It started successfully all times in less than a minute (each time).
However, this err message from watchman is still there.

watchman warning:  opendir(/Users/jerome/Documents/mongoDb/db/diagnostic.data) -> Permission denied. Marking this portion of the tree deleted
To clear this warning, run:
`watchman watch-del /Users/jerome ; watchman watch-project /Users/jerome`


opendir(/Users/jerome/Documents/mongoDb/db/diagnostic.data) -> Permission denied. Marking this portion of the tree deleted
To clear this warning, run:
`watchman watch-del /Users/jerome ; watchman watch-project /Users/jerome`


opendir(/Users/jerome/Documents/mongoDb/db/diagnostic.data) -> Permission denied. Marking this portion of the tree deleted
To clear this warning, run:
`watchman watch-del /Users/jerome ; watchman watch-project /Users/jerome`

and the “ Starting Metro Bundler on port NNN. ” still do not appear. At the opening the messages are same before. But IT WORKS !!! it never worked like this !

THANK YOU VERY MUCH.

1 Like

I’m not sure why Metro is printing out that stuff or why you don’t get the message about starting Metro on port 19001, but I’m glad it’s working for you.

In order to try to sort out the watchman warnings, maybe try this:

echo WATCHMAN_CONFIG_FILE: $WATCHMAN_CONFIG_FILE
ls -ld /etc/watchman.json /.watchmanconfig /Users/.watchmanconfig /Users/jerome/.watchmanconfig /Users/jerome/Documents/.watchmanconfig /Users/jerome/Documents/reactNative/.watchmanconfig /Users/jerome/Documents/reactNative/rn-tp1/.watchmanconfig

I suspect one of those files contains something that’s telling watchman to watch your whole home directory.

Bad news, expo doesn t want to connect anymore, i have tried like 10 times already…
if i connect manualy that comes up

{"type":"initialize_started","port":19001,"projectRoots":["/Users/jerome/Documents/reactNative/rn-tp1"]}
{"type":"transform_cache_reset"}
{"type":"dep_graph_loading"}
error listen EADDRINUSE: address already in use :::19001
Error: listen EADDRINUSE: address already in use :::19001
    at Server.setupListenHandle [as _listen2] (net.js:1306:16)
    at listenInCluster (net.js:1354:12)
    at Server.listen (net.js:1442:7)
    at /Users/jerome/documents/reactNative/rn-tp1/node_modules/metro/src/index.js:257:20
    at new Promise (<anonymous>)
    at Object.<anonymous> (/Users/jerome/documents/reactNative/rn-tp1/node_modules/metro/src/index.js:256:14)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/jerome/documents/reactNative/rn-tp1/node_modules/metro/src/index.js:46:24)
    at _next (/Users/jerome/documents/reactNative/rn-tp1/node_modules/metro/src/index.js:66:9)

i have tried that to see which are the connections on (i don t know if it s usefull…)

jerome@jeromes-MacBook-Pro rn-tp1 % ps -ef | grep node                                                                         
  501  1911     1   0  7:21PM ??         0:03.13 /usr/local/bin/node /Users/jerome/Documents/reactNative/rn-tp1/node_modules/react-native/local-cli/cli.js start --port 19001 --customLogReporterPath /usr/local/lib/node_modules/expo-cli/node_modules/@expo/xdl/build/reporter/index.js --sourceExts expo.ts,expo.tsx,expo.js,expo.jsx,ts,tsx,js,jsx,json,wasm --assetPlugins /Users/jerome/Documents/reactNative/rn-tp1/node_modules/expo/tools/hashAssetFiles.js --reset-cache
  501  1980     1   0  7:28PM ttys001    0:03.19 /usr/local/bin/node /Users/jerome/Documents/reactNative/rn-tp1/node_modules/react-native/local-cli/cli.js start --port 19003 --customLogReporterPath /usr/local/lib/node_modules/expo-cli/node_modules/@expo/xdl/build/reporter/index.js --sourceExts expo.ts,expo.tsx,expo.js,expo.jsx,ts,tsx,js,jsx,json,wasm --assetPlugins /Users/jerome/Documents/reactNative/rn-tp1/node_modules/expo/tools/hashAssetFiles.js --reset-cache
  501  2135  1862   0  7:36PM ttys001    0:00.00 grep node

i have noticed as well that sometimes, it block the browser(firefox), which i need to force-close, then restart.