🐛 Bug Report: Cannot login when using Unix Socket (Cannot get client ip) #354

Closed
opened 2026-02-04 19:04:09 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @Moraxyc on GitHub (Jun 27, 2025).

Originally assigned to: @ItalyPaleAle on GitHub.

Reproduction steps

I’m trying to use pocket-id behind nginx with a UNIX socket.

NGINX config:

server {
	listen 0.0.0.0:443 ssl ;
	listen [::0]:443 ssl ;
	server_name example.org;
	http2 on;
	ssl_certificate /etc/nginx/ssl/lexample.org.pem;
	ssl_certificate_key /etc/nginx/ssl/example.org.key;
	location / {
		proxy_pass "http://unix:/run/pocket-id/pocket-id";
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
	}
}

And then, try to login with a client

Additional context:
https://github.com/gin-gonic/gin/issues/2718

Expected behavior

Login correctly

Actual Behavior

Something went wrong

Version and Environment

v1.4.1

APP_URL=https://example.org
DB_CONNECTION_STRING=user=pocket-id dbname=pocket-id host=/run/postgresql
DB_PROVIDER=postgres
TRUST_PROXY=true
UNIX_SOCKET=/run/pocket-id/pocket-id
UNIX_SOCKET_MODE=0666

Log Output

[GIN] 2025/06/27 - 11:35:36 | 200 |    3.448381ms |                 | GET      "/api/webauthn/login/start"
2025/06/27 11:35:46 Failed to get IP location: failed to parse IP address: ParseAddr(""): unable to parse IP

2025/06/27 11:35:46 github.com/pocket-id/pocket-id/backend/internal/service/audit_log_service.go:47 ERROR: invalid input syntax for type inet: "" (SQLSTATE 22P02)
[2.120ms] [rows:0] INSERT INTO "audit_logs" ("id","created_at","event","ip_address","country","city","user_agent","data","user_id") VALUES ($1$,$2$,$3$,$4$,$5$,$6$,$7$,$8$,$9$)
2025/06/27 11:35:46 Failed to create audit log: ERROR: invalid input syntax for type inet: "" (SQLSTATE 22P02)

2025/06/27 11:35:46 github.com/pocket-id/pocket-id/backend/internal/service/audit_log_service.go:67 ERROR: current transaction is aborted, commands ignored until end of transaction block (SQLSTATE 25P02)
[0.175ms] [rows:0] SELECT count(*) FROM "audit_logs" WHERE user_id = $1$ AND ip_address = $2$ AND user_agent = $3$
2025/06/27 11:35:46 Failed to count audit logs: ERROR: current transaction is aborted, commands ignored until end of transaction block (SQLSTATE 25P02)
[GIN] 2025/06/27 - 11:35:46 | 500 |   28.119935ms |                 | POST     "/api/webauthn/login/finish"
Error #01: commit unexpectedly resulted in rollback
Originally created by @Moraxyc on GitHub (Jun 27, 2025). Originally assigned to: @ItalyPaleAle on GitHub. ### Reproduction steps I’m trying to use `pocket-id` behind nginx with a UNIX socket. NGINX config: ``` server { listen 0.0.0.0:443 ssl ; listen [::0]:443 ssl ; server_name example.org; http2 on; ssl_certificate /etc/nginx/ssl/lexample.org.pem; ssl_certificate_key /etc/nginx/ssl/example.org.key; location / { proxy_pass "http://unix:/run/pocket-id/pocket-id"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } ``` And then, try to login with a client Additional context: https://github.com/gin-gonic/gin/issues/2718 ### Expected behavior Login correctly ### Actual Behavior ![Something went wrong](https://github.com/user-attachments/assets/6d632f26-2393-47eb-8290-ab477976ddf1) ### Version and Environment v1.4.1 ``` APP_URL=https://example.org DB_CONNECTION_STRING=user=pocket-id dbname=pocket-id host=/run/postgresql DB_PROVIDER=postgres TRUST_PROXY=true UNIX_SOCKET=/run/pocket-id/pocket-id UNIX_SOCKET_MODE=0666 ``` ### Log Output ``` [GIN] 2025/06/27 - 11:35:36 | 200 | 3.448381ms | | GET "/api/webauthn/login/start" 2025/06/27 11:35:46 Failed to get IP location: failed to parse IP address: ParseAddr(""): unable to parse IP 2025/06/27 11:35:46 github.com/pocket-id/pocket-id/backend/internal/service/audit_log_service.go:47 ERROR: invalid input syntax for type inet: "" (SQLSTATE 22P02) [2.120ms] [rows:0] INSERT INTO "audit_logs" ("id","created_at","event","ip_address","country","city","user_agent","data","user_id") VALUES ($1$,$2$,$3$,$4$,$5$,$6$,$7$,$8$,$9$) 2025/06/27 11:35:46 Failed to create audit log: ERROR: invalid input syntax for type inet: "" (SQLSTATE 22P02) 2025/06/27 11:35:46 github.com/pocket-id/pocket-id/backend/internal/service/audit_log_service.go:67 ERROR: current transaction is aborted, commands ignored until end of transaction block (SQLSTATE 25P02) [0.175ms] [rows:0] SELECT count(*) FROM "audit_logs" WHERE user_id = $1$ AND ip_address = $2$ AND user_agent = $3$ 2025/06/27 11:35:46 Failed to count audit logs: ERROR: current transaction is aborted, commands ignored until end of transaction block (SQLSTATE 25P02) [GIN] 2025/06/27 - 11:35:46 | 500 | 28.119935ms | | POST "/api/webauthn/login/finish" Error #01: commit unexpectedly resulted in rollback ```
OVERLORD added the bug label 2026-02-04 19:04:09 +03:00
Author
Owner

@ItalyPaleAle commented on GitHub (Jun 28, 2025):

Thanks for the report, fix should be possible.

@ItalyPaleAle commented on GitHub (Jun 28, 2025): Thanks for the report, fix should be possible.
Author
Owner

@Guanran928 commented on GitHub (Jul 9, 2025):

I'm on pocket-id v1.6.1, the issue seems to be not fixed.

[GIN] 2025/07/09 - 10:11:16 | 200 |    7.525779ms |                 | GET      "/api/webauthn/login/start"

2025/07/09 10:11:18 github.com/pocket-id/pocket-id/backend/internal/service/audit_log_service.go:77 ERROR: invalid input syntax for type inet: "" (SQLSTATE 22P02)
[0.579ms] [rows:0] SELECT count(*) FROM "audit_logs" WHERE user_id = $1$ AND ip_address = $2$ AND user_agent = $3$
2025/07/09 10:11:18 Failed to count audit logs: ERROR: invalid input syntax for type inet: "" (SQLSTATE 22P02)
[GIN] 2025/07/09 - 10:11:18 | 500 |    5.051279ms |                 | POST     "/api/webauthn/login/finish"
Error #01: commit unexpectedly resulted in rollback
@Guanran928 commented on GitHub (Jul 9, 2025): I'm on pocket-id v1.6.1, the issue seems to be not fixed. ``` [GIN] 2025/07/09 - 10:11:16 | 200 | 7.525779ms | | GET "/api/webauthn/login/start" 2025/07/09 10:11:18 github.com/pocket-id/pocket-id/backend/internal/service/audit_log_service.go:77 ERROR: invalid input syntax for type inet: "" (SQLSTATE 22P02) [0.579ms] [rows:0] SELECT count(*) FROM "audit_logs" WHERE user_id = $1$ AND ip_address = $2$ AND user_agent = $3$ 2025/07/09 10:11:18 Failed to count audit logs: ERROR: invalid input syntax for type inet: "" (SQLSTATE 22P02) [GIN] 2025/07/09 - 10:11:18 | 500 | 5.051279ms | | POST "/api/webauthn/login/finish" Error #01: commit unexpectedly resulted in rollback ```
Author
Owner

@ItalyPaleAle commented on GitHub (Jul 9, 2025):

My bad, the fix was not complete. https://github.com/pocket-id/pocket-id/pull/737 should actually fix this entirely. Sorry about it!

@ItalyPaleAle commented on GitHub (Jul 9, 2025): My bad, the fix was not complete. https://github.com/pocket-id/pocket-id/pull/737 should actually fix this entirely. Sorry about it!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id#354