Connection refused why?

hi guys,

Why I am having this error:

I have added crosswalk, but on device is not working. Any idea?

Because it violates Content Security Policy…

That’s the reason. Read and setup content security rules in your index.html to allow access to this specific domain.
See also

hi @tomkuipers I have done this setup. But the problem was not fixed. I have for 2 days trying to resolve it.

That is annoying, I am afraid I cannot help. Did you specify the domain in your content security meta tag?

Just for the sake of debugging can you try adding <access origin="*" /> to your config.xml ?

my config.xml seems ok:

<content src="index.html"/>
  <plugin name="cordova-plugin-whitelist" spec="1" />
  <access origin="*" subdomains="true"/>
  <allow-intent href="*" />
  <allow-navigation href="*" />
  <preference name="webviewbounce" value="false"/>
  <preference name="UIWebViewBounce" value="false"/>
  <preference name="DisallowOverscroll" value="true"/>
  <preference name="android-minSdkVersion" value="16"/>
  <preference name="BackupWebStorage" value="none"/>
  <feature name="StatusBar">
    <param name="ios-package" value="CDVStatusBar" onload="true"/>

Up to now I dot not understand why of this problem, once I have setup correctly.

yes. it is here:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' '*' data: gap:; style-src 'self' 'unsafe-inline'; media-src *;script-src 'self' localhost:35729 'unsafe-eval' 'unsafe-inline';">

Do you see this error on actual device only or in browser as well?

device. I have build on phonegap and deployed device.

So in browser everything is fine? sorry if this is a dumb question, i just want to understand that this is actually CORS issue or something wrong with your http request

in browser I have just test with ionic serve and everything is ok. Too tested with ionic view and is ok. But when I generated apk and installed on device, I have received this error =/. I am 2 days trying to fixing. any idea @yurinondual?

thanks for try help me.

is this ios device? try ionic prepare ios, and then ionic build ios, and try to deploy again

its android device samsung T211 model.

If you are connecting to a php file on the server… You can do this !! I used this in my php file…

if (isset($_SERVER['HTTP_ORIGIN'])) {
        header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
        header('Access-Control-Allow-Credentials: true');
        header('Access-Control-Max-Age: 86400');    // cache for 1 day

// Access-Control headers are received during OPTIONS requests

           header("Access-Control-Allow-Methods: GET, POST, OPTIONS");


And this works without … playing with any code n the app

my server is java app. But API has filter for CORS.

Do your server logs give any insights?

@tomkuipers there is not anything in server logs. Its very strange. Because in ionic view the app is working without problem. =/

I ran out of ideas why it is happening to you. Can you try doing ionic plugin list to make sure that whitelist plugin is installed?

hi @yurinondual its is too strange. here the result of plugin I have installed:

$ ionic plugin list
cordova-plugin-crosswalk-webview 1.3.1 "Crosswalk WebView Engine"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-whitelist 1.0.0 "Whitelist"