By ngnblc
Hi,
I have a rest-api written in Java.
When I run my project by java -jar xx.jar command and send a curl request as "curl -X GET “http://mysitename:8084/metadata/city/34” -H “accept: application/json;charset=UTF-8” it works.
But when I enter same address as “http://mysitename:8084/metadata/city/34” to browser, it does not respond and gives this error: “mysitename’s server IP address could not be found”.
I also have swagger dependencies on my pom.xml and “http://mysitename:8084/swagger-ui.html” does not respond also.
So, any help would be very much appreciated.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
What’s failing is DNS resolution. When you are doing curl from the commandline the first place that your nameserver will check for definitions is your /etc/hosts file. If there you have a definition for a domain or name to point to an IP then it will use that to make the request.
When you are going from your browser there is similar behavior depending on whether you are using Mac or Windows. So most likely there is a misconfiguration between your /etc/hosts setting between your server and your local machine which is why when you goto the browser you get the error.
Now if you have a full domain in there, instead of mysitename as a place holder, you would need to check DNS resolution of that domain from both environments to see what the issue is.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.