Capacitor live reload error

Hy
I’m having problems to get the capacitor live reload working.

i run the local websever trough Vite

➜ Local: http://localhost:5173/
➜ Network: use --host to expose

ipconfig gives me

Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::208f:314e:bdf:da7e%18
IPv4 Address. . . . . . . . . . . : 192.168.8.110
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.8.1

in capacitor.config.ts i add

server: {
“url”: “http://192.168.8.110:5173”,
“cleartext”: true
}

i run

npx cap copy
npx cap run android

sometimes it opens the emulator without, sometimes with the following error

× Deploying app-debug.apk to emulator-5554 - failed!
[error] Selected hardware device emulator-5554
Installing
C:\Users\retok\Projects\happynotessveltedexiejscap\android\app\build\outputs\apk\debug\app-debug.apk…
Starting application activity happynote.app/happynote.app.MainActivity…
ADBs is unresponsive after 5000ms, killing server and retrying…
Error: Command failed: C:\Users\retok\AppData\Local\Android\Sdk\platform-tools\adb -s
emulator-5554 shell am start -W -n happynote.app/happynote.app.MainActivity
adb.exe: device still authorizing

    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:519:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)

then in the emulator it shows me the following after a while

Any ideas what im doing wrong?
Thank you for your feedbacks.

Which command are you using to run with vite?

By default, vite only allows running in localhost, if you notice the first lines, it says Network: use --host to expose.

So if you add --host to the vite command you use, it would then expose the live reload server so it’s accessible from the network instead of only from localhost.

Hey Julio thanks for your reply and the hint.
Im runing npm run dev.
npm run dev --host dos not work, but therefore
npm run dev – --host is working fine.
in this blogpost someone explains the extra – needet for it to run.

so it works now. cool :slight_smile:

yeah, you can edit the dev npm script in the package.json to add the --host, or if you don’t edit the dev npm script in the package.json and pass it to the npm run dev in the terminal you need the extra -- before the --host