I made an ionic app with a connection to MYSQL using a PHP API which I put on another computer on Xampp, using it as a remote server in the same network, when I run it on the computer with ionic serve
, it works fine but when I generate the APK, it wont connect to the BD, even tho Im on the same network, does someone knows any way around this?
this is how it looks on the desktop
and this is how it looks on the cellphone
My Answer:
There could be a few reasons why your Ionic app is not connecting to the MySQL database when running on a phone but works fine on the PC with localhost. Here are a few things you can check and try:
1. Make sure that the phone is connected to the same network as the computer running the MySQL database. Sometimes, network configurations can prevent devices from communicating with each other.
2. Check the IP address of the computer running the MySQL database and make sure that the Ionic app is configured to connect to that IP address. If the IP address changes, you will need to update the configuration in your app.
3. Check if there are any firewall or security settings on the computer running the MySQL database that may be blocking connections from external devices. You may need to adjust the settings to allow connections from the phone.
4. Make sure that the PHP API is accessible from external devices. You may need to configure the web server (e.g., Apache) to allow connections from devices other than localhost.
5. Test the connection to the MySQL database using a tool like Postman or a web browser on the phone to see if you can access the API. This can help identify if the issue is with the Ionic app or the network configuration.
By checking these points and troubleshooting the connection, you should be able to resolve the issue and get your Ionic app to connect to the MySQL database on the phone.
Rate this post
4 of 5 based on 2754 votesComments