简体   繁体   中英

error “connection refused” when trying to access to a php page stored on localhost from android app

i am trying to make my first demo app which communicates with remote server. i have a php project setup on localhost and trying a access a php page from android app. when i try to run and access the page i get the error "connection refused" by the app and it stops running. to access the page i am passing "my_ip_address/folder_name/file_name.php" as url . when i give the same link in browser i get the desired data but not in case when i try to connect it through mobile app. i am running the app on my own android mobile .

i have found some same questions but unfortunately because of low points couldn't paste my question to that thread. I also tried out giving the url as "10.0.2.2:8080/folder_name/file_name.php" but it didn't help. i have also updated the manifest file to access the internet. the other solution i found is "my_ip/folder_name/file_name.php" which i am already trying. it wll be great if anyone could help me here.

Thanks for your help in advance !

  1. In your AndroidManifest file you have <uses-permission android:name="android.permission.INTERNET" />
  2. Your android device is connected to same network where is located your web server
  3. Your firewall doesn't blocking incoming connections
  4. Your url is correct (scheme://domain:port/path?query_string#fragment_id): eg http://10.0.2.2/folder_name/file_name.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM