Capacitor live reload error

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. . . . . . . . . . . :
Subnet Mask . . . . . . . . . . . :
Default Gateway . . . . . . . . . :

in capacitor.config.ts i add

server: {
“url”: “”,
“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
Starting application activity…
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
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