Android cannot connect to server if accessing over internet

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Android cannot connect to server if accessing over internet

Postby vismay02 » 29. September 2017 14:58

I have an android app which requires authentication for user.
I am using xampp as my server, I cannot reach server when trying to access it through internet but able to access when on WIFI ie. the same network on which the xampp is.
Are there any necessary changes I have to make.
I have already granted access to all users.
vismay02
 
Posts: 5
Joined: 29. September 2017 14:52
XAMPP version: 3.2.2
Operating System: Windows 7

Re: Android cannot connect to server if accessing over inter

Postby Nobbie » 29. September 2017 20:17

Which IP do you connect via Internet for Xampp?
Nobbie
 
Posts: 9817
Joined: 09. March 2008 13:04

Re: Android cannot connect to server if accessing over inter

Postby vismay02 » 01. October 2017 15:33

While accessing over computer as my PC and the server are on same network I use private IP of my PC.
And while accessing remotely from mobile I use public IP.
vismay02
 
Posts: 5
Joined: 29. September 2017 14:52
XAMPP version: 3.2.2
Operating System: Windows 7

Re: Android cannot connect to server if accessing over inter

Postby Nobbie » 01. October 2017 16:28

Public IP of what? Are your running a router? Or is your PC connected directly?
Nobbie
 
Posts: 9817
Joined: 09. March 2008 13:04

Re: Android cannot connect to server if accessing over inter

Postby vismay02 » 02. October 2017 10:58

In have a router. and my PC is the virtual host connected to that router.
vismay02
 
Posts: 5
Joined: 29. September 2017 14:52
XAMPP version: 3.2.2
Operating System: Windows 7

Re: Android cannot connect to server if accessing over inter

Postby Nobbie » 02. October 2017 13:04

vismay02 wrote:and my PC is the virtual host connected to that router.


Please explain more precisely, what do you mean by that?! A virtualhost and router are totally different thing. You stll did not explain, which IP is the "public IP".
Nobbie
 
Posts: 9817
Joined: 09. March 2008 13:04

Re: Android cannot connect to server if accessing over inter

Postby vismay02 » 03. October 2017 06:39

My PC contains phpMyadmin, I have all my files in htdocs folder. I have a physical server, the public IP belongs to the server and I have configured the PC as virtual server by using router settings. PC is connected to the same server. I have no problem accessing the database while using a web browser from mobile with my internet connection but when i try to login in my application it says "cannot be connected to server." I hope you understood.
vismay02
 
Posts: 5
Joined: 29. September 2017 14:52
XAMPP version: 3.2.2
Operating System: Windows 7

Re: Android cannot connect to server if accessing over inter

Postby Nobbie » 03. October 2017 10:48

vismay02 wrote: I hope you understood.


Hardly - but I might got it. What you call "virtual server" (above you called it "virtualhost", what is competely wrong!) seems to be the same thing what is called "port forwarding" in other routers.

I think, that you installed your problematic application locally onto your (Xampp?) server, and you applied eithe "localhost" or the local IP (like 192.168.x.x) as server name in the installation routine (most applications require a server name, an IP or similar in the installation dialog). At next, probably your application installs a .htaccess file which does a redirect or rewrite, which routes to that server name you applied in the installation. Maybe a redirect happens without .htaccess, but within the PHP code.

If this is the case (what is very common for many CMS like wordpress, joomla etc.), this finally leads to the problem, that the target IP is a LAN IP (or "localhost"), which is unknown in the scope if you connect from outside your LAN. That finally results in "cannot connect to server". You may check the access_log (and also error_log) of your server in order to find out, if redirects are happening and if they succeed or not.

The general solution to that problem is, if you are planning to connect to your application from outer Internet, do NOT provide the LAN IP as server name, provide the external IP instead already at installation time. In an existing installation you might be successfull to edit any kind of config file (for wordpress it is wp-config.php), where you can change the server name also after the installation.
Nobbie
 
Posts: 9817
Joined: 09. March 2008 13:04

Re: Android cannot connect to server if accessing over inter

Postby vismay02 » 03. October 2017 12:13

Thanks a lot for your assistance. I finally made it. Thank You!
vismay02
 
Posts: 5
Joined: 29. September 2017 14:52
XAMPP version: 3.2.2
Operating System: Windows 7


Return to XAMPP for Windows

Who is online

Users browsing this forum: Anancuras\ and 41 guests