0

I am trying to develop a simple android login and registration application which will fetch data from local server(for now). I am using android studio and WAMP server. I have provided the internet permission in the manifest file. I have tried the urls:

  • 10.0.2.2
  • 127.0.0.1
  • 192.168.1.5(my IPv4 address)
  • 192.168.1.5:8080
  • localhost:80

Still evry time it shows

org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.1.5:8080 (or any of the above) refused

I have been trying this and followed every advice but the application stops unfortunately(as the emulator says).I have posted all my required java files and logcat in my previous question here: Unfortunately the application stopped working. It would be of great help if anyone guides me on this.

Community
  • 1
  • 1
R_2293
  • 101
  • 1
  • 2
  • 12
  • This may be a stupid question but the IP listed is the address of the WAMP server, and the android device is connected to the same WiFi network as the WAMP server, correct? Can you access the page from any other device on the network? Can you load it from the web-browser? It may be an issue with routing and your server configuration, not necessarily the app. – Matt Clark May 14 '14 at 17:21
  • try 10.0.2.2 with the port number.. @user3467651 – Lal May 14 '14 at 17:24
  • Try accessing that like `http://10.0.2.2:8080` – Lal May 14 '14 at 17:26
  • @MattClark Yes the android emulator is working on the same WiFi network as the WAMP server. When I tried localhost/webservices/login/register.php or 127.0.0.1/webservices/login.php or localhost:80/webservices/login.php in the mozilla firefox it opens but with others it doesn't load.One more thing,this may sound the stupidest but as with no experience with WAMP, do I have to put it online before using. Although I have tried it with no results. – R_2293 May 14 '14 at 17:32
  • I have done that @Lal but it shows problem loading page in the browser. – R_2293 May 14 '14 at 17:34
  • Is the emulator running on the same machine as the server or on a different machine? – Chris Stratton May 14 '14 at 17:35
  • Yes they are running on the same device.I the httpd.conf file it shows servername as localhost:80 – R_2293 May 14 '14 at 17:49
  • Did you try `http://10.0.2.2:80` ??? – Lal May 14 '14 at 17:54
  • Check your firewalls..Best is that you disable them completely while testing.. – Lal May 14 '14 at 17:59

2 Answers2

0

Use 10.0.2.2:8080 to connect to local server if server is running at port number 8080

Thanks

Mustansar Saeed
  • 2,730
  • 2
  • 22
  • 46
0

I had same problem, until I got here FYI: I had to change port on Wampserver (from port 80 to port 8080, because port 80 was already used (cmd, netstat -aon). In my java class, I tried above addresses, but only 10.0.2.2:8080 helped for me.

Zeghra
  • 447
  • 5
  • 14