Search code examples
spring-bootubuntujar

Springboot make it listen on ipv4


I keep getting a 404 error when trying to run requests while running my Springboot application in jar.

I was advised to look at netstat to check if it is running, I could tell it was by running it twice, once while the app is running and once when it Isn't to verify its live.

It is live however its listening on TCP6, which im guessing is ipv6 instead of ipv4.

I found this related article:

Springboot embedded tomcat binds to IPV6

which I followed and put in application.properties:

server.address=127.0.0.1
server.port=8080

However when running still doesnt work and netstat now shows:

tcp6       0      0 127.0.0.1:8080          :::*                    LISTEN      -

not sure what else to do

I did find another related article here:

https://community.smartbear.com/t5/Collaborator-Questions/server-running-on-IPv6-instead-of-IPv4/td-p/107306

But I do not have a /opt/ccollab_server directory

Any suggestions on getting this to work?


Solution

  • sorry forgot I asked this question, i was told that for some reason it auto executed by default, though i dont know the full reason. This seem to worked when you execute the app like this:

    java -jar -Djava.net.preferIPv4Stack=true appname.jar