Apache-Cordova/PhoneGap Application Error net::ERR_CONNECTION_REFUSED (http://127.0.0.1:5000)

This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io

Hello there distraught Apache-Cordova/PhoneGap developer! Quick post here on the blog to help you with this horrible error message. If you happen to be trying to link up your Apache-Cordova/PhoneGap application running in an Android Emulator to a local development server, such as the builtin Python/Flask development server, and have already made sure to enable the cordova-plugin-whitelist, your problem (and solution) is simple: you cannot link up a cordova app running in an emulator to a local development server running at http://127.0.0.1. Instead, you need to use a tool like ngrok to give your local development server its own public web address such as https://yoursupersweetdevserver.ngrok.io which will then make your local development server accessible to your cordova app.

Please note however, I suggest paying the $60 per year for the ngrok basic subscription so that you have a stable web address that doesn’t change. If you try to accomplish this using their free service, you are going to be in for quite the headache constantly changing the url in your codebase every time you run ngrok!

Hope this post helps some other poor souls out there on the interwebs. This bug caused me quite the headache this afternoon. However, I’m feeling much better after figuring out the solution. And shout out to the guys at ngrok. God bless you!

 

topherPedersen