uax.io - blogs

Stop Windows Ask Firewall When Go Run

When working with REST api with golang on Windows. Every time you run your program, Windows Firewall may complaint like that

windows firewall block go run

You can prevent it by replacing listening address with localhost or 127.0.0.1

// change 
http.ListenAndServe(":3000", r)
// to 
http.ListenAndServe("127.0.0.1:3000", r)

This strict was applied to any frameworks as well, including Fiber, Gin, Iris, and Echo …

Happy coding :)