Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

Runing server on Windows without deal with the Firewall

Why is the firewall constantly asking for http permission for any programms where you need run something in localhost?

When running this example, permission will be asked each time (P.s. Using "go build -o a.exe && a.exe" (Using Go as an example) or something similar may sometimes not help)

Example 1

package main;

import (
"net/http"
"fmt"
)

func requestHandler(w http.ResponseWriter, r *http.Request) {
  fmt.Fprintf(w, "Hello, world")
}

func main(){
  http.HandleFunc("/", requestHandler)
  http.ListenAndServe(":6060", nil)
}
question from:https://stackoverflow.com/questions/65917503/runing-server-on-windows-without-deal-with-the-firewall

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In any program where you work with a specific port, where a new executable file is created each time during implementation, the firewall will consider it as a new file and will ask for permission, the solution is the following:

  1. Go to Windows Defender Firewall, in Left side menu you saw Inbound Rules click there
  2. Then Right Side menu you will see New Rule... click.
  3. Choose Port opened from window -> Next Select TCP, then define which ports you want I choose 6060 click Next again, Choose Allow the connection Next, Check All Next, Give any Name Goland or anything you want and press Finish. Thats it enter image description here

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...