NEW: Subscribe to Hacking with Swift+ and accelerate your learning! >>

localhost works on my MacBook, but other local machines cant see me

Forums > Server-side Swift

http://localhost:8080/home works fine on my laptop, but trying to look at it from a browser on my iPhone doesn't work at all. My MacBook is named Aesop, and the sharing setup says other users should be able to connect to http://Aesop.local:8080/home but safari on the iPad, iPhone, and other Macs on the local network just network times out.

I'm guessing that Catalina is getting in the way, somehow, but I haven't been able to figure out just how. Any ideas?

   

@twostraws  Site Admin

It's possible the macOS firewall is getting in the way, but a better idea is to use your internal IP address – try running ifconfig from the command line and looking for a local IP, such as 192.168.0.1.

   

ifconfig offers up 10.0.0.158, but http://10.0.0.158:8080 doesn't work either.

stackoverflow suggests that I use this bit of code in configure.swift:

// Define Hostname & Port to listen to ...
let myServerConfig = NIOServerConfig.default(hostname: "aesop.local", port: 8080)
services.register(myServerConfig)

and that worked! Now I can't see it on my mac when I use localhost, but I can see it fine on my mac (and other local Macs and local iPhones and local iPads) by using aesop.local. every tenticle has to be in exactly the right place for this to work, but it's beautiful when it does!

Does anyone know if it's possible to configure it so that both "aesop.local" and "localhost" work from my mac? it's not a big deal, but it could be handy for serving seperate websites from the same vapor server... or maybe I'm just getting ahead of myself :)

   

Have you tried changing the hostname to 0.0.0.0?

   

Did you every try to find the best machine for your business, see this blog to read reviews about the latest machines in the market.

   

Hacking with Swift is sponsored by NSSpain

SPONSORED Announcing NSSpain 2020: Remote Edition! An online, continuous conference for iOS developers. We’ll start on Thursday and finish on Friday, with talks, activities, and lots of fun for 36 hours, non-stop. Sound good? Join us!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

Not logged in

Log in
 

Link copied to your pasteboard.