313

When I run a react-native project, I get a error no bundle URL present, but I don't know what mistakes I do, I was very confused.

no bundle url present error

6
  • 4
    I faced this problem in react native iOS app. Just open the xcodeproj in ios folder in xcode and run it from there. Make sure you are not on proxy. Commented Jan 1, 2018 at 7:14
  • 12
    Most of the time, clearing the build directory helps me rm -rf ios/build/
    – onmyway133
    Commented Aug 12, 2018 at 16:44
  • That helps me in most of situations. But in this particular case I was able to fix this error by this command (react-native: "0.60.4"): watchman watch-del-all Commented Dec 13, 2019 at 13:00
  • It usually means that your metro bundler is not running, some people run that in their own terminals or on the standard computer terminal. I usually close the terminal, restart the app and that fixes it. Commented Jun 3, 2020 at 18:12
  • For me it happened after releasing to the App Store. I had to undo the steps described in the Publishing to Apple AppStore page Commented Jul 31, 2021 at 9:24

76 Answers 76

163

Solve the error No bundle URL present by:

  • Running the following command in your project root directory to delete the iOS build directory, and to kill other React Native sessions (assuming they're running on default port 8081) before re-building:

rm -rf ios/build/; kill $(lsof -t -i:8081); react-native run-ios

  • Update your React Native workflow to avoid these error occur by combining the above combination of commands into an alias and appending it to your Bash config file .bashrc with this command:

echo "alias rni=\"kill \$(lsof -t -i:8081); rm -rf ios/build/; react-native run-ios\"" >> ~/.bashrc; source ~/.bashrc

Now you can run React Native iOS build (without worrying about some of the common red error screens of death appearing) with a simple alias shortcut:

rni

5
  • 1
    Very useful for me. The only other thing I had to do was to quit the simulator if not already closed.
    – AnnawanDev
    Commented May 1, 2018 at 20:57
  • glad this is on page 2 500 answers down Commented Dec 1, 2021 at 17:39
  • I have to remove the build folder and it works. Kudos !
    – Sudarshan
    Commented Oct 4, 2022 at 10:38
  • 9
    it returns kill: not enough arguments for me :( anybody know why and how to fix it?
    – Cindy
    Commented Dec 25, 2022 at 5:53
  • @Cindy the lsof -t -i:8081 (list open files) likely returned nothing ( no process running ) so the kill command barfed
    – JamesH
    Commented Apr 3 at 8:56
90

I just ran into this problem as well (first time getting started with React Native). The problem disappeared when - while an ios simulation(react-native run-ios) was running - I ran npm install and then react-native run-ios again. In the terminal window, it showed that it was bundling, and then the simulator showed the welcome screen.

Check this link for briefs after react-native init PropertyFinder line try to use npm start (This one works for me)

========================================================================

UPDATE for 16.9

My port 8081 was blocked by McAfee. Using a different port directly wasn't working react-native start --port=8082 and react-native run-ios --port=8082

Tried almost all solutions given here. but anything didn't work.

        "react": "16.9.0",
        "react-dom": "^16.12.0",
        "react-native": "0.61.5",

Solution:

Searched for 8081 in Xcode and replaced all of them with 8082. Then run the same commands to build and run the app. App works smoothly

react-native start --port=8082
react-native run-ios --port=8082

enter image description here

3
  • 2
    @dcp Have you tried running "react-native run-ios" multiple times while it is already booted up? It seems like every time I spin my app up I need to do it at least twice (waiting about 2 minutes between each time).
    – Skip Suva
    Commented Mar 22, 2017 at 14:27
  • works for me, but would love to find a long-term fix that didn't involve this step each time.
    – mheavers
    Commented Apr 5, 2017 at 18:55
  • react-native run-ios --port=8082 worked for me! Commented Apr 1, 2021 at 22:50
90

This problem happens when you not allow unsecure connections via localhost, or maybe you tried to accept unsecure connections via http.

To fix this, add this on info.plist:

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSAllowsArbitraryLoadsInWebContent</key>
        <true/>
        <key>NSAllowsLocalNetworking</key>
        <true/>
    </dict>
5
  • 12
    What a hero this guy is. Saved me and my macbook from jumping out the window! I had changed my exception domain from localhost to my local network address in Info.plist and hence it was not resolving. I added a block for 'localhost' as an exception domain and it worked.
    – Darius
    Commented Apr 12, 2018 at 12:04
  • 1
    Seriously your answer came in like god to me.... brother you rock ..... I have no words. thanks you, I stuck in it from Thursday. Commented Feb 24, 2020 at 6:42
  • 6
    <key>NSExceptionDomains</key> <dict> <key>localhost</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict> worked for me but same idea Commented Jul 1, 2021 at 3:15
  • 3
    Thanks, a great reminder that saved my day. However to address the No bundle URL present problem we only need the NSExceptionDomains for localhost as mentioned by the previous comment. No need to set NSAllowsArbitraryLoads to true as it turns off ATS completely and you'll need to give Apple a good reason when uploading to the App Store.
    – Marinne
    Commented Jul 8, 2021 at 1:51
  • You're the super hero Commented Nov 2, 2023 at 18:33
53

Had same problem when I did bundle my app. Check that your main.jsbundle is targeted to your main Project

5
  • 3
    This somehow happened to me as part of my react-native 0.60 upgrade.
    – JackDev
    Commented Sep 3, 2019 at 15:00
  • video link for the same, youtube.com/watch?v=eCs2GsWNkoo
    – jrh
    Commented Feb 3, 2020 at 4:23
  • this happened to me as well. but then i clicked on it. but still same issue
    – Jason G
    Commented Jun 18, 2020 at 20:49
  • I am so glad I found your comment, thank you, this was exactly my problem.
    – zkwentz
    Commented Sep 15, 2021 at 21:59
  • it works for me, but the error repeated for the fresh react native project. Have you found a permanent solution? Commented Jun 2, 2023 at 3:03
38

As instructed in the error message:

Agreeing to the Xcode/iOS license requires admin privileges, please run "sudo xcodebuild -license" and then retry this command.

Running the following command worked:

sudo xcodebuild -license
3
  • tks this is work for me after run in terminal and build in xcode after
    – tess hsu
    Commented Dec 11, 2019 at 8:22
  • Nope. Still din't work for me. I am running in a different port , 8081 is blocked Commented Jan 23, 2020 at 11:33
  • I had a MacOS Update before and as app wasn't running after the update with above error message. This solution worked like a charm. Commented Sep 16, 2020 at 2:31
36

Reason:

This is because the app cannot find out the server (which serves the UI - by javascript code).

Solution:

  • Make sure everything related to react native closed (not necessary, just to have clean start for my solution, after my explanation, you can figure out this is needed or not)
  • run npm run start or yarn start first
  • wait for this command done job (usually you will see Loading dependency graph, done.)
  • run react-native run-ios/android

Explanation:

  • React Native comes with 2 parts:

    • Native part
    • Javascript part
  • Build commands:

    • react-native run-ios/android is to build native part then deploy to devices and start app on devices (simulator/emulator/real device). This usually took 3~4 mins to finish.

    • npm run start or yarn start is to build the javascript part and start the dev server to serve the built UI to the app. This usually took 30 secs to finish.

=> Normally, the javascript part finished first then the native part came later. (based on time they used).

=> this is only true for the first time build (fresh build).

=> for re-build:

  • The native part just took 10~15 secs to check changes and because no change for native part => done before the javascript part was built and served. (I am not sure the javascript part was rebuilt or not but it took long time than native part)

  • So that is why we had this issue, the app ran and required thing that did not exist yet.

Bonus:

  • react-native run-ios/android will auto start the dev server for you.
  • That's why when you ran react-native run-ios/android right after react-native init <app_name>, everything ran well. (because auto start feature and the time was took for fresh build as state above).
  • Other "removing" solutions worked because they forced rebuilding.

Time used on this answer was relative to my machine => may different on others.

0
28

Close your simulator and the terminal. Open new one and go to your project, then upgrade your react-native like this:

react-native upgrade

Issue in: Infinite recursion in RCTFatal when the bundle fails to execute.

5
  • 1
    yes, but in my case I didn't need to upgrade. Closing terminal and simulator was enough for me.
    – gianni
    Commented May 4, 2017 at 10:52
  • @gianni What version of react-native are you running now? Commented May 12, 2017 at 18:46
  • 1
    Didn't seem to make any difference, still seeing the error.
    – SSH This
    Commented Jun 16, 2017 at 22:35
  • 2
    This worked for me, but you have to close the simulator as well and then run react-native run-ios Commented Oct 27, 2017 at 5:18
  • 1
    Didn't help ``` info No version passed. Fetching latest... warn Specified version "0.61.5" is already installed in node_modules and it satisfies "0.61.5" semver range. No need to upgrad ``` Commented Jan 23, 2020 at 10:08
21

following these steps:

  • open ios file project with xcode
  • in project bundle delete main.jsbundle file
  • add new empty file by main.jsbundle name
  • Run comment: react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
  • now react-native run-ios

youtube link: https://www.youtube.com/watch?v=eCs2GsWNkoo

4
  • It worked for me. However, local images aren't showing on iOS simulator. Any idea?
    – michael
    Commented Dec 6, 2020 at 2:03
  • if you're running ios 14 on a react <0.62 you'll need to patch
    – cajuuh
    Commented Feb 9, 2021 at 14:41
  • It worked for me but the images is broken now, i get no images... on my iPhone device, HELP?
    – Shay Elbaz
    Commented Apr 4, 2022 at 13:17
  • but, i have a little question, why there is no main.jsbundle shown on my vscode or terminal ? what is it ? now there are 3 changes are in project.pbxproj file about main.jsbundle file what is going on here? what are these files and what was the problem? Commented Dec 8, 2022 at 23:13
16

Try running this code:

$ sudo xcodebuild -license

This may fix the issue. This works for me.

0
12

I had the same error and was able to run the app only through Xcode. react-native run-ios did not work. To resolve the issue you need to remove the build folder at YOUR_PROJECT/ios/build/. After this you should be able to run your app through react-native run-ios again. Hope this helps.

11

For me the issue was it couldn't create the JS bundle. It doesn't state the error when building from Xcode so there is no way for you to know this. To find the error run the following command.

react-native bundle --platform ios --dev false --entry-file index.ios.js --bundle-output ./ios/release/main.jsbundle --assets-dest ./ios/release/main.jsbundle

For me the error was something with missing PureRenderMixin component. To which the solution can be found here: https://github.com/facebook/react-native/issues/13078. Basicly you have to manually install [email protected]. This can be done via running this command.

npm i --save [email protected]

This issue is now happening for everybody because newer versions of react alphas are being released (particularly alpha.5) and they are breaking react-native builds.

4
  • the command 'react-native bundle --platform ios --dev false --entry-file index.ios.js --bundle-output ./ios/release/main.jsbundle --assets-dest ./ios/release/main.jsbundle' will describe any error in building the bundle. until this command is succesfull, run-ios won't work
    – eric f.
    Commented Apr 1, 2017 at 2:13
  • my current error is that the '@connect' of 'react-redux' is not somehow recognized?
    – eric f.
    Commented Apr 1, 2017 at 2:13
  • Maybe try adding "plugins": ["transform-decorators-legacy"] to your .babelrc file. Or try it with the connect HOC.
    – urbancvek
    Commented Apr 4, 2017 at 10:50
  • @urbancvek, for me the error is this The node type SpreadProperty has been renamed to SpreadElement and its referencing @babel library inside of node_modules, I have found nothing that has addressed this.
    – Daniel
    Commented Jun 14, 2019 at 13:31
11

Solution --> npm start then open new Terminal and go to your project path and then hit react-native run-ios it works for me

0
11

Most of the cases this problem occurs when the DNS lookup / IP lookup fails to find localhost.

Solution :

Try adding the localhost ip to your etc host file.

you can add the below lines to your etc host file (/etc/hosts)

127.0.0.1 localhost

255.255.255.255 broadcasthost

::1 l . ocalhost

To confirm this is the issue you can hit the bundle url on safari (if you try it in chrome this will resolve but safari won't be able to resolve it). http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false

4
  • After migrating to a brand new computer, this was what I needed. TY!
    – jeffctown
    Commented Jul 21, 2018 at 12:47
  • Yep same here on a new computer! Commented Jun 16, 2019 at 18:16
  • My problem was setting proxy on my network configuration, I just remove proxy and it works well. Commented Nov 20, 2019 at 12:38
  • It should be http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false now
    – CyberMew
    Commented Aug 4, 2023 at 9:57
11

I had this same issue. But my problem was my Mac and iPhone were not in same wifi network.

So ensure that they are all in same network and rebuild once again. If this is not the case, try the solutions mentioned by other members here.

3
  • 1
    This was the problem for me. It should be the first place you check. Commented Mar 7, 2023 at 20:50
  • You're a hero! No clue why I didn't check it at the first place Commented Mar 20, 2023 at 15:26
  • For me, WLAN was not activated on the iPhone. Once I activated it, the problem went away.
    – Urs Meili
    Commented Feb 26 at 8:34
11

Be sure that your ATS settings are correct in .plist file.

You can find the file at /ios/{{project_name}}/Info.plist

localhost must be defined as exception request target like this:

<key>NSAppTransportSecurity</key>
    <dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>localhost</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

*(dont forget to remove this on release version..)

10

I had to run "react-native start" in a separate terminal. For some reason it wasn't running

Edit: Also, it turns out this was necessary because of a file permission not getting set properly. I am able to fix it by running the following command in an affected project directory.

chmod 777 node_modules/react-native/scripts/launchPackager.command

9

What solved it for me:

  • Open a terminal window
  • cd into YOUR_PROJECT/ios
  • Remove the build folder with rm -r build
  • Run react-native run-ios again

Alternatively, you could open Finder, navigate to YOUR_PROJECT/ios and delete the build folder.

Then run react-native run-ios again.

Source: Andrew Bancroft

8

Just run in Terminal react-native start:

cd your react native app directory/ react-native start 

It will start up the packager, now don't close this terminal window, in another terminal window run your project. This is the only want that I found to get it working properly.

0
6

This is an issue with react-native v0.42.1. Try to close all terminal and XCode instances and run:

launchctl unload ~/Library/LaunchAgents/com.github.facebook.watchman.plist
watchman version
react-native run-ios
1
  • 3
    "This is an issue with react-native v0.42.1. " - It exists with v.0.43 as well.
    – dcp
    Commented Apr 5, 2017 at 20:55
5

check your network proxy , better shut it down.

or u should find an other way to maintain the packager server

3
  • Thanks, I opened the global VPN to cross the Great Fire Wall! Commented May 6, 2017 at 8:27
  • I disabled the automatic proxy configuration in Mac. It worked after 2 days efforts :D...Thanks.
    – Nirav Jain
    Commented Aug 6, 2018 at 18:01
  • I was indeed running a VPN that I didn't even remember. shutting it down worked! Commented May 28, 2019 at 19:12
5

first close the simulator, then run these on terminal

npm install

react-native run-ios
5

I tried all solutions above, didn't work for me. This is what worked for me, you can try this out if the answers above didn't work out for you.

  1. Open your project workspace on Xcode, and delete main.jsbundle file in [PROJECT-NAME]/main.jsbundle

  2. Create a new main.jsbundle, in that same folder. {right-click -> choose new file -> it'll open a dialog box, look for Others section, -> choose Empty -> name the file main.jsbundle -> save

  3. Then go back to the terminal of your project. And run this command:

react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

  1. Start your packager and run the IOS app again

I do hope this helps you out.

5

I am running iOS simulator and this method works:

1. Clean your native project

1.a For Android project

cd android
gradlew clean

1.b For iOS project

cd ios
xcodebuild clean

2. Clean your reactnative cach

2.a If you are using npm

  npm start -- --reset-cache

2.b If you are using yarn

  yarn cache clean

After that you can run your project again.

1
  • What worked for me is simply using npm start and that alone suffice! Starting metro packager first! in a window make it works! No need for --reset-cache too! None of the other elements mattered! Commented Jul 28, 2021 at 13:18
5

In my case I have accidentally deleted this script from the Build Phases in Xcode.

So, Make sure to have this script. If not, just click on " + " & select "New Run Script Phase" then paste the following code.

export NODE_BINARY=node
../node_modules/react-native/scripts/react-native-xcode.sh

enter image description here

4

In my case the problem was fixed by restarting the adb server: adb kill-server && adb start-server

4

check your 'localhost' key at NSExceptionDomains dict in info.plist

if it doesn't exist, it causes error.

4

I have found the easiest/quickest way to bypass this is to exit the app within the simulator (2 x Cmd + Shift + H) and re-launch.

0
3

It has happened to me as well, after restarting my mac. There's a launchPackager terminal window opening up when you run your app on the simulator. I closed that window and terminated the process (I also cloosed the simulator), then run again react-native run-ios and everything works fine.

3

I had this issue happen for me as well...the issue was the packer wasn't running it seemed probably because my default shell was zsh. react-native tires to open a new terminal window and run .../node_modules/react-native/packager/launchPackager.command but this didn't run. Manually running that (and keeping it running) fixed this for me.

0
2

Assuming that you are using nvm and multiple versions of node installed, here is the solution:

  1. Say that you run npm install -g react-native-cli in node v6.9.5.
  2. Now make node v6.9.5 as default by running nvm alias default 6.9.5
  3. Now run react-native run-ios

The problem is, you have multiple versions of node installed via nvm and to install react-native-cli you have switched or installed latest version of node, which is not marked as default node to point in nvm yet. When you run react-native run-ios this opens up another new terminal window in which default nvm is not pointed to the node version where you have installed react-native-cli. Just follow the above setup, I hope that should help.

Not the answer you're looking for? Browse other questions tagged or ask your own question.