tauri: [bug] `error sending request for url (http://192.168.0.x:1420/)` on iOS
Describe the bug
Whenever I build an app for iOS and run it on a physical device I cannot get the view to load. Using dev works alright but build never loads. I always get error sending request for url (http://192.168.0.x:1420/)
Reproduction
I’m just using all the vanilla templates from https://beta.tauri.app/guides/create/#using-create-tauri-app. I’ve specifically tried bun and pnpm for svelte and basic JS.
Expected behavior
The built app should load on device.
Full tauri info output
[✔] Environment
- OS: Mac OS 14.4.1 X64
✔ Xcode Command Line Tools: installed
✔ rustc: 1.77.2 (25ef9e3d8 2024-04-09)
✔ cargo: 1.77.2 (e52e36006 2024-03-26)
✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
✔ Rust toolchain: stable-aarch64-apple-darwin (default)
- node: 20.12.2
- pnpm: 9.0.2
- yarn: 1.22.22
- npm: 10.5.0
- bun: 1.1.2
[-] Packages
- tauri [RUST]: 2.0.0-beta.15
- tauri-build [RUST]: 2.0.0-beta.12
- wry [RUST]: 0.39.1
- tao [RUST]: 0.27.0
- tauri-cli [RUST]: 2.0.0-alpha.14
- @tauri-apps/api [NPM]: 2.0.0-beta.8
- @tauri-apps/cli [NPM]: 2.0.0-beta.13
[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../dist
- devUrl: http://localhost:1420/
- bundler: Vite
[-] iOS
- Developer Teams: <REDACTED>
Stack trace
No response
Additional context
There’s some Discord conversation about this here: https://discord.com/channels/616186924390023171/1227758916872441856 And here: https://discord.com/channels/616186924390023171/1230704798488072282/1230718571080974336
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 37 (4 by maintainers)
I resolve this problem by change devUrl:“http://localhost:1420” to http://0.0.0.0:1420 or your PC ip in tauri.conf.json.
Just in case someone went through this, as of today’s latest RC release, it can still happen (windows 11), using npm, this makes it works (it exposes through all interfaces, like 0.0.0.0 would do, not sure why it does not here):
I succeeded in solving the problem, and the method was very simple. Change ‘beforeDevCommand’ in ‘tauri.config.json’ to ‘pnpm dev --host’ to make web content accessible on the LAN. Then change the IP in ‘devUrl’ to the developer’s computer, so that the mobile phone can get web resources from the computer. 我成功地解决了这个问题,方法很简单。需要将
tauri.config.json中的beforeDevCommand改为pnpm dev --host使得网页内容可以在局域网中访问。再将devUrl中的IP改为开发者电脑的,使得手机可以从电脑端获取网页资源。I thought I was getting a similar issue for android dev from windows machine But it was caused by being connected to a VPN 🤦
Its work for me
“build”: { “beforeDevCommand”: “pnpm dev --host”, “devUrl”: “http://<your host>”, “beforeBuildCommand”: “pnpm build”, “frontendDist”: “…/dist” },
I personnaly solved it, on windows 11, by using the local address
127.0.0.1(Angular project) package.json
tauri.config.json
tauri android devI see the port forwarding can fail if there’s more than one device connected. Let’s see if there’s a way to fix it.
I’m getting the same error on my Android device, but it also happens with the
tauri devcommand.Does anyone know why these requests are happening via WiFi? The best UX would be to have the same thing as CapacitorJS… where everything happens through the USB cable.
I don’t know about iOS, but Android has this very neat thing called
adb reversethat can forward any network calls made to a port to the ADB connection. For example:Makes it so when you access your phone’s
localhost:3000you’ll be actually accessing your Laptop’slocalhost:3000React Native uses that technique and we could probably use that in Tauri too… removing the need for these devices to share a common connection ( like Wifi ). Maybe iOS has a similar thing too