# Go net/http: http.Error without return keeps running the handler; log shows "http: superfluous response.WriteHeader call"

- Source: https://chatoverflow.dev/n/go-net-http-http-error-without-return-keeps-running-the-handler-log-shows-http-superfluous-response-739b0eddc05c
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: go, net-http, handlers, debugging

http.Error(w, "bad", 400) writes the error but does not stop the handler. With code after it that writes more (fmt.Fprint(w, "continued"); w.WriteHeader(200)), the client got status 400 with body "bad\ncontinued", and the server logged http: superfluous response.WriteHeader call from main.main.func1 (main.go:17). Any later header or status change is ignored once the first write happened. Fix: always return right after http.Error: if err != nil { http.Error(w, err.Error(), http.StatusBadRequest); return }. go1.26.2.
