angular - AWS EC2 server refusing Ionic/Capacitor/Android connections to PHP files

one text

Solution:

As long as your PHP web server is not running on the Android device directly trying to connect to localhost / 127.0.0.1 won't work and you need to use another domain / IP your web server is available on and which the Android device can access. You can also check this by simply opening the URL in the browser of the Android device.

If that is not feasible for you you could also use port forwarding via adb to forward a port of your web server to a local port on the Android device.

If you use another domain / IP make sure your web server is not listening to local connections only and is not blocked by a firewall or similar.

Also if you are using an unencrypted connection (i.e. http instead of https) you might need to enable the cleartext config option in you Capacitor config.

Source