Reputation: 21
I am writting spring service(rest) for mobile app.I am writing test service with localhost and running on virtual machine(windows) but i can see http://localhost:8080/rest
only on the same computer.What should i do to use my rest api from another machine?ip
aplication properties
spring.data.mongodb.host=localhost
spring.data.mongodb.port=
spring.data.mongodb.database=mongoTest
Upvotes: 1
Views: 3603
Reputation: 554
You are talking about two different things.
Your property file is about connection to your mongodb instance.
localhost is only a shortcut "saying" that the application can be found on your local machine.
having localhost in this property file means that the application server and the database server are on the same physical machine.
If you want to access your API from another machine, you can use the IP address of the server.
On Windows, you can know this address by typing ipconfig in a command line.
On Linux, it would be ifconfig.
Later, you can try to work with machine name instead of the IP address.
Upvotes: 1