Nativescript - How to handle No Connection


Hello NS forum,
I have a quick question and a problem,
I would like to create NoConnection page when user is not able to connect to Server …
Im using fetchModule, and doing it something like this:

        .then(function(result) {
            if (result && result.ok) {
                return true;
            } else {
                    moduleName: config.offlinePage,
                    transition: {
                        name: 'slide',
        .catch(function() {
                    moduleName: 'offlinePage.js',
                    transition: {
                        name: 'slide',

But I would like to make it global like to Listen for
System.err: Connection refused
and then to push user to Offline page


You may check the connectivity type on failure to determine whether the device has a active network connection.


Ok I understand but I dont want to check if device has internet connectivity, I want to check if device can recieve response from source ??


@manojdcoder … I’m working with Vue-Nativescript and I’m trying to connect to my local host but I’m getting connection refused, how do I go about this?


When you say localhost, I assume you have a local server running in your machine. Inside Simulator localhost won’t be reachable, hit with your local IP.


I have my local server running and also I’m testing with a physical device ( an android phone)


Still the answer is same, localhost is valid only to your machine not to your network. It has to be accessed via IP only.