Check Internet Connection In App Inventor

Checking connection is very easy. You can use a Web component and try connecting to a website. is a very good candidate for that since it’s very unusual for google server to be down. Below is a snippet where I have a button and when you click the button, it tries to connect to You can download the project CheckConnection and try changing the google url to something that doesn’t exist and see the result. Say if you set the value of the variable googleUrl to, you will have a 404 error. If the responseCode sent from the server is 200, that means you have connection.

For a list of response codes and what they mean, see HTTP status codes.

Here’s the project source – CheckConnection



  1. Hello,

    I’m looking for a way to such action, whether it is possible to:

    a) when you start Screen1, the application checked if an active internet connection, if so OK, run Screen2

    b) if there is no Internet connection, run Screen3

    I thought your code to check for my needs. Unfortunately does not work as it should, there is an error code 1101 for the server. I can customize it to my needs.

    Please help, thanks Tom

    • Did you try this on a device? You should test connection related apps on your device. You can try first the sample CheckConnection provided above.

    • Hello. If the web server does not work, how to check internet connectivity?

  2. Hello again,

    I thank you for your help;) objective achieved. My code is able to:

    First checks the Internet connection (Screen1)
    2 if there is an active Internet connection, launches Screen 3
    3 if there is not an active Internet connection, launches Screen 2

    I will try to fine-tune the code to my needs.

    Regards, Tom

    • I’m looking for a solution like yours. U have to send me the maid to file aia have a study .

  3. Hi,
    I have a question, how to build the code in the app inventor not inventor2? Is it possible, I can not odnaleść ingredients to inventor2?

    Regards, Tom

  4. hi,

    Thank you for your help again;). After a large reconstruction of the code, I got what I was looking for. You are great

    Regards, Tom

  5. Can i call ajax request xmlhttp request from app inventor

  6. Hi,
    I have a question, how can i read the unique ID of an NFC tag on android, please (App inventor 2)

    Regards, Kato

  7. Hi,
    I have a question,how can I post a username and password to a website..?
    Is it possible in appinventor..?

    • You can build the url with necessary data. Do a search in google. This has been explained in many sites.

  8. Hi, have you tried this app on Lollipop ? I’ve tried it on a Nexux 5 with lollipop and it doesn’t seems to work. It shows that he doesn’t have internet connection, even when the device is connected. Any ideea why ? On other Android versions the app works perfect.
    Thank you.

  9. The ResponseCode from when you are using Web.Get on Lollipop is 302, not 200, and so, the answer of the App is that you have no internet connection, even if you are connected. Do you know how can i check the Android version in Appinventor, so i can modify the ‘IF condition’ acoording to it ?
    Thank you very much for your answer.

    • 302 is valid with redirection. Modify the ‘if’ statement to “if responseCode=200 or responseCode=302”, it’s good.

  10. Ok. I’ll do that. I thought that 302 is a real error, not an ‘OK’answer. I was already looking for another way to check the internet connection, no way I was thinking about implementing this very simple solution (so stupid of me:) ). Thank you very much, again. By the way, there is some kind of method in appinventor for sending a ‘ping’ message to an IP and check if you get the reply ?
    Thank you !

    • It does work. It sends 302 for redirect and 200 for final entry. Since we only catch the first response, we get 302.

  11. This doesn’t work anymore. I had it working just fine on an old app, needed it in a new one, and it fails. I tried the old app, doesn’t work either. I get an Error 1101, unable to get response. Can you help me with a sollution

    • You need to upgrade your companion first.

  12. Thanks Sajal for this tutorial!
    It’s working on Android 5.1 adding “if responseCode=200 or responseCode=302″.

    Have you done in App Inventor an Internet speed meter?

    Thanks again!

    • There are too many variables involved to do that. Do a search online and you will see what I mean. An example is – while you are making the speed test, say device is scheduled to fetch mails in the same time. Your speed test will be affected.

  13. Hi
    First thanks For Sharning and i useing your source code “CheckConnection” i want this app ping evrey 1 min ,What should I do?

    • Have a Clock and set its interval to 2000 ms. Then every time Clock fires, ping.

  14. First of all, thank you for sharing

    I want change “CheckConnection” it, for example, every 1 minute ping and, if conection down show a msg

    what should I do?

  15. Thank you very much for your response
    and how to i can get ,(for example), 3 website from textbox and app ping all web sit in order?

  16. Thank you very much for fast response
    how to run app in background?

  17. Oh,That’s no way?

    I have some questions that I did not find in your post:

    What is a Code for Error connect to the Internet?

    How do identify that a site is busy (responseCode)?

    What is a responseCode for Down URLs?

    this Is code are reliable?

    Thank you

  18. I have a texbox for Enter url from user,When i,press Button home on the my Phone to visible screen,and again restore it,textbox is clear!!do you have solution

    Thank you

  19. hello, i want to build voltmeter by using apps and internet. Do you have any suggestion to build it if i want to read data of voltage from circuit that i created on arduino. means that data from arduino will send to android phone using mit apps inventor 2 using internet.

  20. Hi Sajal. Is there a way to diactivates the Error 1001 Message? Or it always will be displayed when no internet connection was detected?

  21. Hello Sajal, thanks for the tutorial and the example provided.
    Im actually using Thunkable, spin off AI2, and i have Screen1 Webviewer component.

    I would like that if there is no connection the app will go to Screen2 where i had put two textbox.

    Please can you help me how i can achieve that?

      • Uhm seems nothing happening Sajal. If there is no connection the app does nothing, just show the default webview error message.

        I just added the web1 component in the designer and the 2 blocks to my Screen1

        • I misunderstood. I thought if connection is successful, you want to launch another screen. You want other way around. In web1.GotText, have a if statement where it checks if the response code is NOT 200. If not 200, open your other screen. Do the same in errornumber=1101.

          • Yes Sajal i want in the other way.
            But the problem is that the Web1 seems is not triggered when the app open.
            I added When Screen1.OnInitalize do call Web1.get but with no success, where im wrong?
            If you want i can provide the .aia app file (but don’t know if it’s compatible with AI2 as i created in Thunkable)


  22. @Simone, send me your .aia. Hopefully that will open in ai2.

    • You didn’t set the Url of Web1. Try setting it to as I did above in the tutorial. Use an actual device to test, not an emulator. Everything should work unless something is wrong with thunkable thing that you used which I have no idea about. Contact them.

  23. Ok i will try Sajal, but something isn’t clear to me, why i have to set the Url of Web1 if i already set an Url in the WebViewer component?
    I just want that if there is no connection the app will go to Screen2, if there is connection it will display the content of the WebViewer component.

    • Web viewer has nothing to do with web. Viewer just views a page like a browser while web is much more. It can post a request, fetch a server response, etc. web is used to get a response from any server. In my tutorial, I chose google.

      • I solved Sajal! Thanks for all the support.

  24. Thank you for this post.

    I am trying to open a URL that does not exist. For some reason screen1.erroroccured event is not triggered. Only when I disable the DATA on the phone it is triggered. Do you know why and how to resolve?

    • See first what response code you get. I provided a link in this tutorial to see what those response codes mean. You should receive 404 (not found). By the way, having no connection is not an error. It’s a state.

  25. Hello.

    In app inventor 2 is possible to check if the user using WiFI or 4G?

    • I am afraid you cannot. Look for a site/api that checks if the mobile network is 3g/4g/etc and use that.

  26. I want make an app that itself starts as user turn on data connection like whats app , hike .
    Please provide solution and also want to know that how it can be run inside without user permission

  27. I want to.make app which should start as user turn on data connection.

  28. Hi Sajal,
    I am working on an project where i need to pass a hostname in the url instead of the IP Address. Is it possible in App Inventor.
    Is there a way of getting the IP of the HOST using getByName() or some other java method.
    Any pointers in this direction will help.

  29. i am unable to use check connection

  30. sir can you help me?
    i’m trying to create a simple registration (part of my app),
    i’m sure that the db credentials is correct and when running the app doing registration, it returns “SUCCESS” but the data isn’t save on my database what i’m doing wrong?
    php script:
    im really don’t know what to do know and can’t find solution on the internet
    i hope you can give me some tips sir
    thank you very much

  31. Hi Sir,

    Can you help me to send sms using app inventor while compiling it gives error only one screen i checked it gives error ie.ymail.
    i googled but didn’t get result.

    • Can you please post the error screenshot here?

  32. Hi!. I’ve tried this and works superb!, thanks for that ^^. But my application needs to work with prepaid navigation, so it’s very important to restrict and reduce the data used on this operation. Is there any way to make this a bit more cheaper?. Thanks for all your work!!.

  33. thanks sir for your important subject
    i want ask you abaut send firebase cloud msg (notification )
    i set every thing in google console and firebase console
    what can i do in my project to receive my msg ?

  34. the else part will never work…. because there is simply no connection to get the text file.

  35. Hello Mr. Dutta,

    I am new to android apps. I am trying to make an app for my office purpose in which files (jpg, pdf) stored in a ftp server can be viewed in app. I can make a connection to office ftp server through VPN. I request u to help me in providing some useful tips about VPN to my office server.


  36. Hi Mr. Dutta,
    I am using a program on App Inventor 2 to communicate with ESP8266 wifi module. As a test, initially I wrote so that the smartphone will send messages type=1=, type=2= etc (= is the delimiter used by program on ESP8266. When the ESP reads the message, it will send a response “Response=1”, “Response=2″ etc. When I was testing in one of the iterations, there was a bug in Type=4 iteration and the program stopped. In Type 4, I am getting the current day (as 1 for Sunday, 2 for Monday etc.) and time (11:51;42 AM etc) from the clock function. Now, even though the program is fixed, whenever I start the app, I get the following message on the smartphone app ” Unable to get a response with the specified URL:http://?type=4=3=1:51:13 PM= where the current day and time represent the day and time when the app is currently running. How do I clear this? I tried looking at the files in the smartphone but could not zero in on the file to remove.

  37. How to monitor the internet connectivity. For instance, suppose it loses internet connectivity and again gains the connectivity we want to change the pages based on connectivity spontaneously.

    • Use a timer with 5000 ms (5 seconds) to check connection.

  38. I’m getting the 1101 error whenever I try running any apps that have the Web component. Any tips on how I can eliminate that error? I have tried the apps using my home wifi, school wifi and with mobile data but still no luck. Please help!

  39. I have a cell phone with “2 chips”. I need to turn data usage on and off whenever I want. Is there any block / event in appinventor2 with the function of picking the chip and turning on and off data usage?

  40. hi,

    I want to check wifi esp8266 connection in app invertor.How does it?

  41. Excellent tutorial Sajal.

  42. When my app first check internet connection, it’s always false.

  43. I want to connect to an esp8266 that is in softap mode, running an internal webserver (without internet connection), when I run the app (written in appybuilder and using the taifu wifi extension) it connects, it tells me that it does not have access to the internet (in the smartphone) and return to the pre-established connection with the internet, can you help me please, thanks, apologies for my english

  44. thanks a lot!

  45. Hi Sajal,
    good work Your CheckConnection app!
    My mobile sometimes loses the 3G internet connection and manually I stop and restart data connection for 2/3 times.
    Your app check correctly the status, but is possible to diseble and enable the mobile data connection via code?
    Many thanks,

Submit a Comment

Your email address will not be published. Required fields are marked *