Running Spring app on local network IP 192.168.X.X
Solution 1
all you need to do is add this to your app.properties (or whatever you called spring properties file)
server.address=<your_ip>
Solution 2
I have the same problem. My goal is to run a Springboot application on Windows (My local computer) and allows my mobile phones to access the application.
I have solved my problem by:
1.Set static IP Address as mentioned above.
I use command prompt to run ipconfig
and I can see:
IP address=192.168.1.99
Subnet Mark=255.255.255.0
Default gateway = 192.168.1.1
Then I copy those values to setup the static IP.
I set preferred DSN Servr = 192.168.1.1
and I leave Alternate DNS server empty.
2. In "application.properties" file of Springboot project
add server.address=192.168.1.99
Thank you for all advice above :)
![jarosik](https://i.stack.imgur.com/JokL6.png?s=256&g=1)
Comments
-
jarosik almost 2 years
I run my Spring web app on localhost, so both addresses work:
I would also like to see this app running on concrete IP of my machine (in order to access it from a mobile, but that is less important here). I used ipconfig to obtain my IPv4, but when I use it like so:
I get 'this site can't be reached'. That's still on my local machine, not mobile. Is there something else I should set up to make it work?
EDIT: here's a PrintScreen illustrating the problem. I don't think this is a matter of app configuration, because server console should show up in all cases, even if there is no app deployed or running.
-
jarosik almost 8 yearsshouldn't I see at least a server console? This should load without any app configuration
-
jarosik almost 8 yearsI have Windows 10. I completely stopped a FireWall service
-
jarosik almost 8 yearsThis is actually Win 7, I'm using WildFly 10 and STS 3.8.1
-
WrRaThY almost 8 yearsI don't really know what you mean by seeing a server console, but you should configure your app :) in case you're just developing something internally - just run ipconfig, copy your address and paste it in the configuration file. In case you want it to be more stable than your DHCP ip address - check out Saraths answer
-
Pierre almost 8 yearsok, so your client is windows7 and your server is windows10? That is important (not on the same machine = networking rules apply). Is your Win7 machine on the same network as the Win10 server? Ex: are both computers connected to the same router? If they are not on the same subnet, then you can't connect using an IP of the format 192.168.x.x
-
jarosik almost 8 yearsThis is a single machine with Win7, and there is no other (I made a mistake before, sorry for the mess). Ultimate goal is to access an app running on localhost from mobile device, but for now this is not relevant. See PrintScreen I added.
-
jarosik almost 8 yearsSame machine, all on localhost. See the PrtScreen
-
WrRaThY over 7 yearsI'm far from being an expert in WildFly, but I know one thing for sure. Spring and any JEE app containers don't mix well. There are things that can be managed on both Springs and containers side. Usually there are some problems involved and configuration of the container is generally more important. That said I have to ask: why did you choose WildFly? Is there anything that you need from an application server?
-
Paramesh Korrakuti almost 5 yearsThis may not work for container based deployments, since most of the times we do scale up and down our apps.