I have a golang http server which is supposed to listen on port 80.
My problem is:
The program compiles normally but exit without listening. When I change the port to 8080 everything works normally and I can access my web page.
- I am using Ubuntu as my operating system.
- I added an Ingress Rules which allows port 80
I don't understand why my server is not listening on port 80 but listening on all other ports.
Thank you for your help.
package main
import (
"fmt"
"net/http"
)
func hello(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "<p>Hello world!</p>")
}
func main() {
http.HandleFunc("/", hello)
http.ListenAndServe(":80", nil)
}
Check for the error
output on my local is this, but it can have other reason