Reaching local cloud while debugging on iPhone

I’ve been running my iOS app in the Xcode simulator and it reaches my Vapor services at http://localhost:8080/api/ just fine but now I need to run the iOS app on an iPhone.

I tried changing the “localhost” part of baseURL in ResourceRequest.swift with my Mac’s IP address but still doesn’t work.

If there’s a section in the book about testing on a device I couldn’t find it.

Any pointers appreciated.


Hey @gonzalo so you have a couple of options. By default a Vapor application will only allow connections from the same IP address (basically on the same machine). So you need to set the hostname (or the allowed connections address) to which tells the app to allow connections from any IP address.

You can do this two ways:

  1. Edit the Run scheme in Xcode and add an argument for --hostname
  2. In configure.swift register a NIOServerConfig with the hostname set to

One you’ve done one of those, when you start the app you’ll see it say something like server starting on

Hope that helps!

1 Like

That worked! I do have the server URL set in two places so I needed to change it in ResourceRequest.swift and Auth.swift to include my Mac’s IP address. Now my iOS app running on my iPhone can reach my Vapor login and data services running on my Mac. Awesome!

Thank you so much. Stay well.

1 Like