Suppressing Accept Incoming Network Connections warnings on OSX

Lee Provoost
2 min readFeb 4, 2016

--

I recently started using fresh (https://github.com/pilu/fresh) to monitor my Go files during development. It monitors your source files and rebuilds your application and restarts your server when changes are detected.

Lovely tool, but on OSX I kept receiving a warning: “Do you want the application xxx to accept incoming network connections?”. EVERY. SINGLE. TIME.

Some people tell you to sign the app to avoid this. Unfortunately, that doesn’t work.

Thing is that fresh constantly rebuilds your app. Generating a new, unknown, unsigned, and untrusted application. So OSX continues complaining about it.

I very coincidentally stumbled on a golang-nuts Google Groups discussion where they point out that you need to explicitly serve your server from localhost.

http.ListenAndServe(“localhost:8080”, nil)

Instead of:

http.ListenAndServe(“:8080”, nil)

They got this solution from a live coding session with Brad and Andrew on Youtube.

The way I do it is to have a command line flag (but you can use an environment variable as well) that tells the app what environment it runs in (e.g. DEV, PRD) and then you check that in your main() code:

flag.StringVar(&fEnvironment, “env”, “DEV”, “environment: DEV (development), STG (staging), PRD (production)”)
flag.Parse()
if fEnvironment == “DEV” {
n.Run(“localhost:” + fPort)
} else {
n.Run(“:” + fPort)
}

--

--

Lee Provoost

Building software and sipping cocktails. Not always in that order.