When we were trying to connect an android app with the php localhost services it was giving an error: cannot connect to the server please check your network connection.
Code independently was working but not when we were connecting Android app to localhost code. It was working on uploading the code to the server instead of localhost.
After some research we came to know the real problem is Air Gapping.
Air Gapping (Definition from whatis.com): Air gapping is a security measure that involves isolating a computer or network and preventing it from establishing an external connection.
An air gapped computer is physically segregated and incapable of connecting wirelessly or physically with other computers or network devices. To prevent unauthorized data extrusion through electromagnetic or electronic exploits, there is often a specified amount of space between the air gapped system and outside walls and between its wires and the wires for other technical equipment.
So the problem was that our company was using an isolated network for the machines to prevent them to be accessible by outside network and the mobile testing device was using some other network connection (a different wifi), so it was not able to communicate with the code running on my local machine.
Solution is to ask your system administrator to get some permission changes made for your testing device.
Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need any Android or iOS Mobile App developed please contact us at email@example.com