tvOS - Cannot connect to localhost

I am testing some tvOS code and it works great on the Simulator however on the Dev Kit running OS beta 2 I am receiving the following error:

2015-09-27 11:10:29.797 RWDevCon[272:46267] SSSQLiteDatabase: Could not open database, resetting: [23, /var/mobile/Library/Cookies/] _CFURLRequestCopyStorageSession deprecated 2015-09-27 11:10:29.810 RWDevCon[272:46267] ITML: Setting [1] for Ignore HTTP Cache 2015-09-27 11:10:34.886 RWDevCon[272:46267] ITML: Setting [3] log level 2015-09-27 11:10:34.887 RWDevCon[272:46267] ITML : Failed to load launch URL with error: Error Domain=NSURLErrorDomain Code=-1004 "Cannot connect to localhost" UserInfo={NSUnderlyingError=0x137d2dee0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "Could not connect to the server." UserInfo={ _kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1, NSLocalizedDescription=Could not connect to the server.}}, NSErrorFailingURLStringKey=http://localhost:9001/js/application.js, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Cannot connect to localhost}

Swift Code: class AppDelegate: UIResponder, UIApplicationDelegate, TVApplicationControllerDelegate { var window: UIWindow?

var appController: TVApplicationController? /
static let TVBaseURL = "http:/
static let TVBootURL = "\(AppDelegate.TVBaseURL)js/application.js" /

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {

    window = UIWindow(frame: UIScreen.mainScreen().bounds)

    let appControllerContext = TVApplicationControllerContext()

    guard let javaScriptURL = NSURL(string: AppDelegate.TVBootURL) else {
        fatalError("unable to create NSURL")

    appControllerContext.javaScriptApplicationURL = javaScriptURL
    appControllerContext.launchOptions["BASEURL"] = AppDelegate.TVBaseURL

    appController = TVApplicationController(context: appControllerContext, window: window, delegate: self)

    return true


**JavaScript/server code:**
App.onLaunch = function(options) {

// 1 var alert = createAlert("Welcome to tvOS Programming", "It will be Awesome!"); // leaving 2nd parameter with an empty string navigationDocument.presentModal(alert); }

// 2
var createAlert = function(title, description) {

var alertString = `<?xml version="1.0" encoding="UTF-8" ?>

var parser = new DOMParser();
var alertDoc = parser.parseFromString(alertString, "application/xml");

return alertDoc


Starting the Server:

python -m SimpleHTTPServer 9001

NB: Allow Arbitary Loads is set to YES


The devkit is another computer on your network, and you can't host the JSTVML server on the kit itself. You need to host it on an external server (in this case your development machine is that external server).

Make sure your devkit and your development computer are on the same network.

Set up your js code to access your computer by specifying the IP address.

Ex: (pretending that is the ip address of your development server and 9001 is the port.)

You should be able to test this out by accessing it in your browser first (to make sure you're development computer is returning the .js file correctly).

Once you know the 'server' is working, setup your javascript to access that remote location.

Hope this helps.

Or You can user Node.js

Before you start. you should check this documentation

Second. Whatever you need. You can find template project below this link.


  1. Copy template desktop of this project.
  2. cmd + space | open terminal
  3. sudo npm install http-server -g
  4. cd /Users/"yourusername"/Desktop/tvOS/TVMLCatalogUsingTVMLTemplates
  5. http-server -p 7575

ok Now yo should update AppDelegate.swift file.

**static let TVBaseURL = "http://localhost:7575/"**

Need Your Help

floating divs jumps below each other when minimize browser window

html css

I have 3 divs in my page header.First div is faculty logo, second div is website title and third div is university logo.

Access denied creating xml file in apache tomcat

ajax xml jsp tomcat

I am creating an Exam Portal, in it there is a JSP calcresult.jsp which calculates the result of exam and shows the result also after that it creates an xml file which stores the result so that exa...