F3RN1
F3RN1

Reputation: 179

Tomcat not working on Localhost

I have an Android application that connects to a servlet in a Tomcat server.

I have Tomcat server coupled to eclipse.

The IP address indicated to the Android application to connect to the Tomcat servlet is

http://10.0.2.2:8080/Middleware/UsuarioServlet

Why if I put

http://localhost:8080/Middleware/UsuarioServlet

not work and gives an error? If I have installed Tomcat on the same machine should work with localhost too.

Upvotes: 0

Views: 333

Answers (2)

Rodrigo Villalba Zayas
Rodrigo Villalba Zayas

Reputation: 5636

Localhost refers to the Android device in this case. Use the IP address 10.0.2.2 to refers to your development machine. Read more about here!

Upvotes: 1

Andremoniy
Andremoniy

Reputation: 34920

Because your Android application runs on virtual device, which has another IP in your local intranet, it isn't localhost.

Upvotes: 2

Related Questions