Ionic 5 capacitor Connection error: net::ERR_CONNECTION_REFUSED

I have already created a new project on ionic 5 capacitor.

During build is giving issues on API and plugins. Have turned from localhost to private IP and the same issue.


Have tried below steps for a build and also debug with andorid studio and same thing.

ionic build --prod
npx cap sync
npx cap open android

npm run build --prod
npx cap copy
npx cap open android

ionic capacitor run android --prod --release
ionic capacitor sync android
ionic capacitor run android -l --external --adress
ionic capacitor run android --no-sync --target Pixel_3_API_30

On android studio have modified the fiiles of AndroidManifest to allow trafic config.xml to allow all origins, alos @xml file

try to execute just “ionic serve --prod” and see if the warning still appears

2 Likes

Problem fixed as below.

npm run ng build – --configuration production
npx cap copy
npx cap open android

1 Like

For me, same problem occurs when the capacitor or ionic or angular’s target NPM version is different.