Response with status: 0 for URL: null. But only sometimes and only on ios

Hello there,
I have strange thing going on:

If i run my app on an iOS device, the http requests dont work correctly.
Round about 70% of these requests are failing with the error “Response with status: 0 for URL: null”.
But if i repeat them a few times, at one point, they just work. But the next time, they fail again. So i try them a few tmies again and then it works again.
On browser and android, everything works just fine.

Does anyone have an idea, why this problems occur?

best regards

I have the same problem, did you fix this?

No, i couldnt fix it.

So i created a workaround:
If my http request fails, i just try it again and again (5 times max) until it it works.
Here a short snippet of my code, i hope, it helps somehow:

// This is the standard http/post function used systemwide
post(endpoint, payload, add_device_infos=false):Promise<any>{
	//create a unique hash for every request that comes in and save it in an array with its counter at value 1
	let requestHash=this.getHash();

	//send the request
	return new Promise((resolve, reject) => {''+endpoint,payload,{}).map(res => res.json()).subscribe(data => {
			//request successfull, resolve the promise
		err => {
			//Request fails, so i handle the failure
			this.postFailure(endpoint, payload, requestHash, resolve, reject);

//handle the failure
postFailure(endpoint, payload, requestHash, resolve, reject){

	//if the request hash doesnt exist or the counter for this request hash reached 5, i stop trying and accept, that the request failed for good
	if(!this.requests[requestHash] || this.requests[requestHash]>=5){
	  delete this.requests[requestHash];

	//Increase the counter for this request hash and try again
	this.requests[requestHash]++;''+endpoint,payload,{}).map(res => res.json()).subscribe(data => {
		//request successfull, resolve the promise
	err => {
		//Request fails, so i handle the failure
		this.postFailure(endpoint, payload, requestHash, resolve, reject);

It will be a CORS issue - look at the headers for the requests - the server needs to allow certain headers, also note that there is a preflight request - see the OPTIONS request


Also see:

But if it is a CORS issue, it wouldnt work at all. But it works flawless on Android and the browser.
And on iOS it sometimes works on the first try and sometimes on the third try (same request).
So i dont see, why this is a CORS issue…
But if you could convince me, i would be more then happy to have at least any clue

1 Like

In Ionic 3 iOS uses WKWebView which means that CORS is now mandatory - Android doesn’t use CORS, neither does the desktop browser


WKWebview was definitely the right way to go with Ionic 3 (although more difficult to use because of CORS) as Apple recommend that you don’t use the older UIWebView which was used in Ionic 1 - see:

Actually further up the page explains it a bit better:

let headers: any = new Headers({
‘Content-Type’: ‘application/json’,
‘Access-Control-Allow-Origin’: ‘’,
‘Access-Control-Allow-Headers’: '
‘Access-Control-Allow-Methods’: ‘*’
let options = { headers: headers };, myData, options)
.subscribe(data => {

}, err => {

still I’m facing issue in above code…please help me out from this… Thanks in advance… In android its working fine but in iOS(11.4) I’m facing

“Response with status: 0 for URL: null” issue.

Hello Skee,

I have same issue in android, rest api not working in android emulator or device and give error: Response with 0 for Url: null.
and finally i got solution that there is cordova platform android version issue, if there is cordova Android version is 6.3 then it’s working properly but it there is cordova Android version is 7.0 or 7.1.1 then it’s not working for me.
So, I think in ios you should check your ios platform version and then try again.
You can check ios or android version using cli command.
ionic info

Also check your all cordova plugins is installed or not. If someone is missing then install it manually and check again.
You can check your cordova plugins using cli command.
cordova plugin -ls

I think it is helpful you.


1 Like

Solved my problem too.

I removed android 7.0.0 and installed 6.3.0.

Works fine!


I have the same error. Android works but iOS fails? Any help?

Hi EveryOne I have found the best possible solution for WKWebView and it works fine
This issue happened due to the WKWebView Mostly in IONIC 3

So, the very simple way to use the WKWebView in Ionic is that You Must uninstall the previously installed UIWebView from the plugin by running the following command.

  • ionic cordova plugin remove cordova-plugin-ionic-webview

After that try to add the WKWebView Plugin with this command

  • ionic cordova plugin add cordova-plugin-wkwebview-engine

When the WkWebView plugin is installed the very next thing is to add the following lines in the config.xml file

feature name=“CDVWKWebViewEngine”

param name=“ios-package” value=“CDVWKWebViewEngine”


preference name=“CordovaWebViewEngine” value=“CDVWKWebViewEngine”

preference name=“WKWebViewOnly” value=“true”

After doing all that when you try to run the application and hit some api call you will get the preflight issue in that due to CORS so to fix that. Simply run the following command

  • ionic cordova plugin add cordova-plugin-wkwebviewxhrfix

After adding the above plugin the CORS issue will be resolved

Happy Coding

1 Like

Thankyou for the help.

Precisely we need to add this to config.xml under ios section

<platform name="ios">
    <preference name="WKWebViewOnly" value="true" />

    <feature name="CDVWKWebViewEngine">
        <param name="ios-package" value="CDVWKWebViewEngine" />

    <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />