简体   繁体   中英

Curl is not accepting localhost from linux , but accepting localhost when checked through gitbash

I have a spring boot application which I bought up through java -jar spring-0.0.1 snapshot.jar and running it in backgroung and then hitting the curl command

curl --request GET -H content-type:"application/json" http://localhost:8082/sample

giving me Hi as response which is not the one which I pass from my restcontroller.

But if I am hitting the same from gitbash, i am able to get th eproper response.

FI: curl --request GET -H content-type:"application/json" http://ipv4address:8082/sample is working from linux.

can somebosy pls help me to get this, how to use localhostr with curl from linux script.

Thanks Deepak

can you try this: http://127.0.0.1:8082/sample instead of http://localhost:8082/sample

I was able to get the answer, it is because in my unix box the previous java jar was running in background and because of that I was getting the old result every time. I killed that background process and checked, now it is working fine. Thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM