If the connection via an IP address fails then this doesn't appear to be a DNS related issue.
For starters, make sure that the IP address is correct.
You mentioned "it just only works as a local connection". It's not clear to me what you mean by "local". Care to clarify?
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin