简体   繁体   English

尝试从Android应用访问本地主机上存储的php页面时出现错误“连接被拒绝”

[英]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. 我在本地主机上设置了一个php项目,并尝试从android应用访问一个php页面。 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 . 访问页面,我将“ my_ip_address / folder_name / file_name.php”作为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 . 我在自己的android手机上运行该应用程序。

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. 我还尝试将URL设置为“ 10.0.2.2:8080/folder_name/file_name.php”,但这没有帮助。 i have also updated the manifest file to access the internet. 我还更新了清单文件以访问Internet。 the other solution i found is "my_ip/folder_name/file_name.php" which i am already trying. 我发现的另一个解决方案是我已经尝试过的“ my_ip / folder_name / file_name.php”。 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" /> 在您的AndroidManifest文件中,您具有<uses-permission android:name="android.permission.INTERNET" />
  2. Your android device is connected to same network where is located your web server 您的android设备已连接到Web服务器所在的同一网络
  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 您的网址是正确的(方案:// domain:port / path?query_string#fragment_id):例如http://10.0.2.2/folder_name/file_name.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 docker镜像中的spring boot应用程序错误连接到localhost:5433被拒绝 - spring boot app in docker image error Connection to localhost:5433 refused 尝试连接到本地主机上的套接字时出现连接拒绝错误 - Connection Refused Error when attempting to connect to socket on localhost Android:连接被拒绝错误 - Android: Connection refused error 尝试通过 kubernetes DNS 访问 kubernetes pod 时连接被拒绝 - Connection refused when trying to access a kubernetes pod via kubernetes DNS 为什么在PHP和android中尝试使用套接字时连接被拒绝? - why connection is refused while trying to use socket in PHP and android? Spring 在 localhost 上启动应用程序:连接被拒绝 - Spring Boot app on localhost: connection refused 尝试从Android上的Java restAdapter访问localhost - Trying to access localhost from a Java restAdapter on Android 在 Android 模拟器中从本地 FTP 服务器下载时出现错误“227 进入被动模式”/“连接被拒绝” - Error "227 Entering Passive Mode"/"Connection refused" when downloading from local FTP server in Android emulator tomcat10主页无法通过键入localhost加载:8080错误:ERR_CONNECTION_REFUSED - tomcat10 home page can not load by typing localhost:8080 error: ERR_CONNECTION_REFUSED SocketCluster - 无法从 Android 应用程序连接到服务器 - 连接被拒绝 - SocketCluster - Unable to connect to server from Android app - Connection refused
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM