ionic Failed to load webpage with error: Could not connect to the server
I had the same problem.
I opened the ios project in the platform folder via Xcode, but I forgot that the codebase in the Xcode folder was not up to date and therefore broken.
To get the new code in your Xcode project use the command:
ionic cordova prepare ios
If your problem is rooted in the same as mine this should help.
This error may also occur if you open the project using Xcode after used the live debugging with the emulator
ionic cordova emulate ios --livereload -lc
To solve the issue, close Xcode and build the project again using
ionic cordova build ios
Then build and run using Xcode.
I encountered this issue when I tried to run my Ionic 4 app on an iOS device.
What solved it for me, was running the dev server on all network interfaces using the --address
option, for example:
ionic cordova run ios --address=0.0.0.0 --debug --consolelogs -l