Remote Debugging with Charles Proxy

By  on  
Charles Proxy

The most difficult part of supporting TV apps when you didn't create them and don't have access to the source code is debugging them when asked for help.  It's almost an unfair request -- "we wont give you access to edit the code but we want you to give use the answer."  Editing remote code is a pain...but thanks to Charles this practice got a whole lot easier.  Charles allows me to intercept calls to remote CSS and JavaScript files and substitute my own, allowing for infinitely easier debugging of remote code I don't have access to change.

Charles is loaded with features, so much so that it becomes confusing.  I'm hoping to make that more simple for you; in this post I will walk you through file replacement for the purpose of remote debugging of web apps.

Charles is a paid app which provides a 30 day trial.  I've not been paid or even asked to endorse Charles; it's the tool I use for remote debugging so I've chosen to write about it.

Charles can do just about everything but we're going to limit this post to solving one frequent problem:  swapping out a remote file for a local file that we can substitute, thus allowing us complete control over its contents and allowing us to an opportunity to fix any problems!

Remote Debugging

To swap out a remote file for a local file, the first step is using the Charles menu and choosing Tools>Map Remote.  The Map Remote Settings window pops up with a listing of remotes you've defined; to add one, click the "Add" button and you'll see the following screen:

Charles Proxy

The top block is for remote file settings and the second block is for your local substitution settings.  This means your file must be "served" (not using the file:// protocol); you can use Python or Node.js to easily serve a directory.  Assuming you're serving the file, you'll enter the remote URL settings first, followed by your local settings.  Here's an example:

Charles Proxy

The screenshot above shows me replacing a production MDN .js file with a local file.  To ensure the local file is being used, place a special console.log call at the top of the file and ensure the message is within the console.

This is just one of the simpler features that Charles provides but it has made my life much, much easier.  Debugging remote applications went from impossible to effortless after inputting a few rules into Charles.  If you have a good method for accomplishing this without Charles, I'd love to know, please share!

Recent Features

  • By
    Welcome to My New Office

    My first professional web development was at a small print shop where I sat in a windowless cubical all day. I suffered that boxed in environment for almost five years before I was able to find a remote job where I worked from home. The first...

  • By
    CSS vs. JS Animation: Which is Faster?

    How is it possible that JavaScript-based animation has secretly always been as fast — or faster — than CSS transitions? And, how is it possible that Adobe and Google consistently release media-rich mobile sites that rival the performance of native apps? This article serves as a point-by-point...

Incredible Demos

  • By
    Create a Download Package Using MooTools Moousture

    Zohaib Sibt-e-Hassan recently released a great mouse gestures library for MooTools called Moousture. Moousture allows you to trigger functionality by moving your mouse in specified custom patterns. Too illustrate Moousture's value, I've created an image download builder using Mooustures and PHP. The XHTML We provide...

  • By
    Chris Coyier’s Favorite CodePen Demos

    David asked me if I'd be up for a guest post picking out some of my favorite Pens from CodePen. A daunting task! There are so many! I managed to pick a few though that have blown me away over the past few months. If you...


  1. So far I had been editing the source codes by logging in through the FTP, taking back ups and editing and uploading the edited version. It would be interesting to try Charles to find out if it could help cut out some steps.

  2. Trevor W

    Thanks so much for the help! Especially the links to python HTTP hosting. I do have a question though – I ran everything like you said but no .js file is swapped :(
    When I go to my file at in the browser, it also shows a Charles Proxy error that it can’t connect to remote host. Actual error: Connection refused (Connection refused)
    What is wrong? Is there some proxy setting buried somewhere that I need to change in order to access locally hosted files?

  3. You can also try the Requestly Redirect URL feature ( to redirect your remote JS/CSS code to your local files.

    Requestly is available as a browser extension so it doesn’t impact your network settings by applying proxy to all applications. It’s pretty simple to use and comes with a free plan.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!