Running Spring app on local network IP 192.168.X.X

14,178

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>

just as described here

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 :)

Share:
14,178
jarosik
Author by

jarosik

intermediate java developer

Updated on July 26, 2022

Comments

  • jarosik
    jarosik almost 2 years

    I run my Spring web app on localhost, so both addresses work:

    http://localhost:9999/app

    http://127.0.0.1:9999/app

    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:

    http://192.168.1.4:9999/app

    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.

    enter image description here

  • jarosik
    jarosik almost 8 years
    shouldn't I see at least a server console? This should load without any app configuration
  • jarosik
    jarosik almost 8 years
    I have Windows 10. I completely stopped a FireWall service
  • jarosik
    jarosik almost 8 years
    This is actually Win 7, I'm using WildFly 10 and STS 3.8.1
  • WrRaThY
    WrRaThY almost 8 years
    I 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
    Pierre almost 8 years
    ok, 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
    jarosik almost 8 years
    This 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
    jarosik almost 8 years
    Same machine, all on localhost. See the PrtScreen
  • WrRaThY
    WrRaThY over 7 years
    I'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
    Paramesh Korrakuti almost 5 years
    This may not work for container based deployments, since most of the times we do scale up and down our apps.