Connection refused when running on device

Hi all

Am calling a json service on a local weblogic server. When runned on a local browser i am able to retrieve my json response. But when runned on my device with the command: “ionic run android --device” am getting the following error:

Failed to load resource: net::ERR_CONNECTION_REFUSED

My code:

$scope.url = "http://localhost:7101/appdk03_portal_
$http.get($scope.url).then(function (response) {…

I also tried changing the url like this:

$scope.url = "
$http.get($scope.url).then(function (response) {…

I guess it only works running on a emulator. I want to run my app in my device.

Any help with be appreciated

I think its CORS issue , You need to enable CORS in your API.

Can u describe in more details how i am suppose to setup CORS in my API. Maybe links?

Which platform you are using for design API ?

Read these articles for enable CORS

For -

For php -

Thx it worked by setting http default post content type:

$[“Content-Type”] = “application/x-www-form-urlencoded”;

Then on the weblogic server setting up a filter:


import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;

public class SimpleCORSFilter implements Filter {

public void init(FilterConfig fc) throws ServletException {

public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
    HttpServletResponse response = (HttpServletResponse)res;
    response.addHeader("Access-Control-Allow-Origin", "*");
    response.addHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
    response.addHeader("Access-Control-Max-Age", "3600");
    response.setHeader("Access-Control-Allow-Headers", "X-ACCESS_TOKEN, Access-Control-Allow-Origin, Authorization, Origin, x-requested-with, Content-Type, Content-Range, Content-Disposition, Content-Description");
    chain.doFilter(req, res);

public void destroy() {


changing web.xml: