[GH-ISSUE #1362] http: response.WriteHeader on hijacked connection log warning #961

Closed
opened 2026-05-07 00:29:09 +02:00 by BreizhHardware · 5 comments

Originally created by @warioishere on GitHub (Jun 1, 2025).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1362

Hi there,

I'm occasionally seeing the following log warning in my ntfy server logs:

2025/06/01 16:36:07 http: response.WriteHeader on hijacked connection from heckel.io/ntfy/v2/server.(*Server).handleError (server.go:416)

This seems to indicate that the server attempted to write an HTTP response header to a connection that was already hijacked (e.g. for long polling or streaming).

Context

  • ntfy Server Version 2.12
  • Deployment: binary
  • Reverse Proxy: haproxy

Expected behavior

Ideally, this warning should not occur. If the connection has been hijacked (for streaming), the server should probably avoid calling WriteHeader.

Notes

  • This may not affect functionality directly, but it clutters logs and could mask real issues.
  • I suspect this happens when an error occurs after the connection was hijacked but before the stream was fully established or closed.

Would it be possible to suppress this log or handle such cases more gracefully?

Thanks for your work on ntfy!

Originally created by @warioishere on GitHub (Jun 1, 2025). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1362 Hi there, I'm occasionally seeing the following log warning in my ntfy server logs: ``` 2025/06/01 16:36:07 http: response.WriteHeader on hijacked connection from heckel.io/ntfy/v2/server.(*Server).handleError (server.go:416) ``` This seems to indicate that the server attempted to write an HTTP response header to a connection that was already hijacked (e.g. for long polling or streaming). ### Context * ntfy Server Version 2.12 * Deployment: binary * Reverse Proxy: haproxy ### Expected behavior Ideally, this warning should not occur. If the connection has been hijacked (for streaming), the server should probably avoid calling `WriteHeader`. ### Notes * This may not affect functionality directly, but it clutters logs and could mask real issues. * I suspect this happens when an error occurs *after* the connection was hijacked but before the stream was fully established or closed. Would it be possible to suppress this log or handle such cases more gracefully? Thanks for your work on ntfy!
BreizhHardware 2026-05-07 00:29:09 +02:00
Author
Owner

@wunter8 commented on GitHub (Jun 1, 2025):

This seems to be caused by my PR here: https://github.com/binwiederhier/ntfy/pull/1338

I was trying to pass errors (authentication errors specifically) in response to websocket requests since wss://ntfy.sh/secret-topic-that-requires-auth/ws would return a 200 code and an empty body instead of returning a 403 and indicating to the user that authentication is required.

Not sure right now what the best fix is

<!-- gh-comment-id:2927835070 --> @wunter8 commented on GitHub (Jun 1, 2025): This seems to be caused by my PR here: https://github.com/binwiederhier/ntfy/pull/1338 I was trying to pass errors (authentication errors specifically) in response to websocket requests since `wss://ntfy.sh/secret-topic-that-requires-auth/ws` would return a 200 code and an empty body instead of returning a 403 and indicating to the user that authentication is required. Not sure right now what the best fix is
Author
Owner

@bonfiresh commented on GitHub (Feb 3, 2026):

i have the same issue with the latest release

<!-- gh-comment-id:3844359680 --> @bonfiresh commented on GitHub (Feb 3, 2026): i have the same issue with the latest release
Author
Owner

@binwiederhier commented on GitHub (Feb 3, 2026):

i have the same issue with the latest release

It's not really an issue, it's just log spam. But it is annoying, I agree.

<!-- gh-comment-id:3844396179 --> @binwiederhier commented on GitHub (Feb 3, 2026): > i have the same issue with the latest release It's not really an issue, it's just log spam. But it is annoying, I agree.
Author
Owner

@binwiederhier commented on GitHub (Feb 4, 2026):

Fixed in github.com/binwiederhier/ntfy@08eaafa77b

<!-- gh-comment-id:3847682656 --> @binwiederhier commented on GitHub (Feb 4, 2026): Fixed in https://github.com/binwiederhier/ntfy/commit/08eaafa77b8284d0651e424667342abf2cb13d45
Author
Owner

@warioishere commented on GitHub (Feb 4, 2026):

thanks!

<!-- gh-comment-id:3847689350 --> @warioishere commented on GitHub (Feb 4, 2026): thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#961
No description provided.