[Bug]: Socket failed to connect when logging in with authelia #3021

Open
opened 2026-02-20 03:04:27 -05:00 by deekerman · 8 comments
Owner

Originally created by @SamsiFPV on GitHub (Jun 12, 2025).

What happened?

When I am logging in with authelia, the notification pops up "Socket failed to connect".
If I log in with password, everything works.

The only differences I can see on those two requests is the authelia session cookie.

What did you expect to happen?

I expect the app to work with the authelia login

Steps to reproduce the issue

  1. Log in with authelia
  2. Website displays "Socket failed to connect" after a few seconds.

Audiobookshelf version

v2.24.0

How are you running audiobookshelf?

Other (list in "Additional Notes" box)

What OS is your Audiobookshelf server hosted from?

Other (list in "Additional Notes" box)

If the issue is being seen in the UI, what browsers are you seeing the problem on?

None

Logs


Additional Notes

abs is running on truenas, accessed via a reverse proxy made with nginx.

Originally created by @SamsiFPV on GitHub (Jun 12, 2025). ### What happened? When I am logging in with authelia, the notification pops up "Socket failed to connect". If I log in with password, everything works. The only differences I can see on those two requests is the authelia session cookie. ### What did you expect to happen? I expect the app to work with the authelia login ### Steps to reproduce the issue 1. Log in with authelia 2. Website displays "Socket failed to connect" after a few seconds. ### Audiobookshelf version v2.24.0 ### How are you running audiobookshelf? Other (list in "Additional Notes" box) ### What OS is your Audiobookshelf server hosted from? Other (list in "Additional Notes" box) ### If the issue is being seen in the UI, what browsers are you seeing the problem on? None ### Logs ```shell ``` ### Additional Notes abs is running on truenas, accessed via a reverse proxy made with nginx.
Author
Owner

@Vito0912 commented on GitHub (Jun 12, 2025):

Shows symptoms of a crash.
Please check the crash log if available, which should be located under the metadata folder.
If you use docker, check the docker logs as an alternative.

@Vito0912 commented on GitHub (Jun 12, 2025): Shows symptoms of a crash. Please check the crash log if available, which should be located under the metadata folder. If you use docker, check the docker logs as an alternative.
Author
Owner

@SamsiFPV commented on GitHub (Jun 13, 2025):

The container logs from TrueNAS:

2025-06-13 06:11:49.605180+00:00[2025-06-13 08:11:49.604] INFO: [Auth] User "samsi" logged in from ip ::ffff:192.168.1.144
2025-06-13 06:11:57.859700+00:00[2025-06-13 08:11:57.859] INFO: [Auth] User "samsi" logged in from ip ::ffff:192.168.1.144
2025-06-13 06:19:24.409802+00:00[2025-06-13 08:19:24.409] INFO: [Auth] User "samsi" logged in from ip ::ffff:192.168.1.144

Logs from the metadata/logs/daily folder:

{"timestamp":"2025-06-13 08:11:49.605","source":"Auth.js:892","message":"[Auth] User \"samsi\" logged in from ip ::ffff:192.168.1.144","levelName":"INFO","level":2}
{"timestamp":"2025-06-13 08:11:57.859","source":"Auth.js:892","message":"[Auth] User \"samsi\" logged in from ip ::ffff:192.168.1.144","levelName":"INFO","level":2}
{"timestamp":"2025-06-13 08:19:24.409","source":"Auth.js:892","message":"[Auth] User \"samsi\" logged in from ip ::ffff:192.168.1.144","levelName":"INFO","level":2}

Also tried switching log level to debug, but nothing interesting there either. The application doesn't seem to crash, it just doesn't like the websocket request with the authentication cookie

I think it's the size of the cookie, my request is 1.7kB big. It works with a request size of 700 Bytes.

@SamsiFPV commented on GitHub (Jun 13, 2025): The container logs from TrueNAS: ``` 2025-06-13 06:11:49.605180+00:00[2025-06-13 08:11:49.604] INFO: [Auth] User "samsi" logged in from ip ::ffff:192.168.1.144 2025-06-13 06:11:57.859700+00:00[2025-06-13 08:11:57.859] INFO: [Auth] User "samsi" logged in from ip ::ffff:192.168.1.144 2025-06-13 06:19:24.409802+00:00[2025-06-13 08:19:24.409] INFO: [Auth] User "samsi" logged in from ip ::ffff:192.168.1.144 ``` Logs from the metadata/logs/daily folder: ``` {"timestamp":"2025-06-13 08:11:49.605","source":"Auth.js:892","message":"[Auth] User \"samsi\" logged in from ip ::ffff:192.168.1.144","levelName":"INFO","level":2} {"timestamp":"2025-06-13 08:11:57.859","source":"Auth.js:892","message":"[Auth] User \"samsi\" logged in from ip ::ffff:192.168.1.144","levelName":"INFO","level":2} {"timestamp":"2025-06-13 08:19:24.409","source":"Auth.js:892","message":"[Auth] User \"samsi\" logged in from ip ::ffff:192.168.1.144","levelName":"INFO","level":2} ``` Also tried switching log level to debug, but nothing interesting there either. The application doesn't seem to crash, it just doesn't like the websocket request with the authentication cookie I think it's the size of the cookie, my request is 1.7kB big. It works with a request size of 700 Bytes.
Author
Owner

@advplyr commented on GitHub (Jul 8, 2025):

Did you resolve this?

@advplyr commented on GitHub (Jul 8, 2025): Did you resolve this?
Author
Owner

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

Negative.
I tried again now, and now it brings me this error:

Image
@SamsiFPV commented on GitHub (Jul 9, 2025): Negative. I tried again now, and now it brings me this error: <img width="281" height="83" alt="Image" src="https://github.com/user-attachments/assets/3dbda954-f887-40b5-bead-3dec7aa4862c" />
Author
Owner

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

Can you please provide the status code of the request and any other information connected to the request.

Idk if we do something special for cookies, but iirc cookies should be fine up to 4kb. The header is not allowed to be bigger than 8kb (So maybe you have other values in the header maybe?)

@Vito0912 commented on GitHub (Jul 9, 2025): Can you please provide the status code of the request and any other information connected to the request. Idk if we do something special for cookies, but iirc cookies should be fine up to 4kb. The header is not allowed to be bigger than 8kb (So maybe you have other values in the header maybe?)
Author
Owner

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

Okay, this is weird. I have tried again, this time with a clean chromium browser.
After logging in with Authelia, I get a "This site can't be reached".

These are the failed requests:

Image

The first failed request had this request URL:

https://abs.example.ch/auth/openid/callback?code=authelia_ac_RqagEsjAer-PfhV-nsIJkfK2tY6rxmnu7QZjcOqTm3Q.ULPwy_tX2jyw2rzPeyvtsSsUmmTtkuq25RxTLhqJ6zs&iss=https%3A%2F%2Fauth.example.ch&scope=openid+profile+email&state=LYFvk6R2q4PdoPLEi_HTSqEXIqO75DTpTezn-HGdMGc

And these request headers:

:authority
abs.example.ch
:method
GET
:path
/auth/openid/callback?code=authelia_ac_RqagEsjAer-PfhV-nsIJkfK2tY6rxmnu7QZjcOqTm3Q.ULPwy_tX2jyw2rzPeyvtsSsUmmTtkuq25RxTLhqJ6zs&iss=https%3A%2F%2Fauth.example.ch&scope=openid+profile+email&state=LYFvk6R2q4PdoPLEi_HTSqEXIqO75DTpTezn-HGdMGc
:scheme
https
accept
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
accept-encoding
gzip, deflate, br, zstd
accept-language
en-GB,en-US;q=0.9,en;q=0.8
cache-control
no-cache
cookie
auth_method=openid; openid_id_token=MYTOKEN
authelia_session=$_Szi-KCRKgXfSmE6jgVLoMa7fjDByiz; auth_cb=https%3A%2F%2Fabs.example.ch%2Faudiobookshelf%2Flogin%2F
pragma
no-cache
priority
u=0, i
sec-ch-ua
"Not)A;Brand";v="8", "Chromium";v="138"
sec-ch-ua-mobile
?0
sec-ch-ua-platform
"Linux"
sec-fetch-dest
document
sec-fetch-mode
navigate
sec-fetch-site
same-site
sec-fetch-user
?1
upgrade-insecure-requests
1
user-agent
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

On Firefox I no longer get the Axios error, instead it logs me in and again: "Socket failed to connect"

That looks like this:

Image

The first response is NS_ERROR_UNKNOWN_HOST, the rest is NS_ERROR_CONNECTION_REFUSED:

Image
@SamsiFPV commented on GitHub (Jul 9, 2025): Okay, this is weird. I have tried again, this time with a clean chromium browser. After logging in with Authelia, I get a "This site can't be reached". These are the failed requests: <img width="709" height="152" alt="Image" src="https://github.com/user-attachments/assets/d7809a1a-9de9-4e92-a2b2-e30d21c39ae1" /> The first failed request had this request URL: ``` https://abs.example.ch/auth/openid/callback?code=authelia_ac_RqagEsjAer-PfhV-nsIJkfK2tY6rxmnu7QZjcOqTm3Q.ULPwy_tX2jyw2rzPeyvtsSsUmmTtkuq25RxTLhqJ6zs&iss=https%3A%2F%2Fauth.example.ch&scope=openid+profile+email&state=LYFvk6R2q4PdoPLEi_HTSqEXIqO75DTpTezn-HGdMGc ``` And these request headers: ``` :authority abs.example.ch :method GET :path /auth/openid/callback?code=authelia_ac_RqagEsjAer-PfhV-nsIJkfK2tY6rxmnu7QZjcOqTm3Q.ULPwy_tX2jyw2rzPeyvtsSsUmmTtkuq25RxTLhqJ6zs&iss=https%3A%2F%2Fauth.example.ch&scope=openid+profile+email&state=LYFvk6R2q4PdoPLEi_HTSqEXIqO75DTpTezn-HGdMGc :scheme https accept text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 accept-encoding gzip, deflate, br, zstd accept-language en-GB,en-US;q=0.9,en;q=0.8 cache-control no-cache cookie auth_method=openid; openid_id_token=MYTOKEN authelia_session=$_Szi-KCRKgXfSmE6jgVLoMa7fjDByiz; auth_cb=https%3A%2F%2Fabs.example.ch%2Faudiobookshelf%2Flogin%2F pragma no-cache priority u=0, i sec-ch-ua "Not)A;Brand";v="8", "Chromium";v="138" sec-ch-ua-mobile ?0 sec-ch-ua-platform "Linux" sec-fetch-dest document sec-fetch-mode navigate sec-fetch-site same-site sec-fetch-user ?1 upgrade-insecure-requests 1 user-agent Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 ``` On Firefox I no longer get the Axios error, instead it logs me in and again: "Socket failed to connect" That looks like this: <img width="1709" height="792" alt="Image" src="https://github.com/user-attachments/assets/12448031-2cf5-49fd-9573-d3a96a64761c" /> The first response is NS_ERROR_UNKNOWN_HOST, the rest is NS_ERROR_CONNECTION_REFUSED: <img width="199" height="145" alt="Image" src="https://github.com/user-attachments/assets/63dc9e31-89bf-4917-981d-7e585a951eb5" />
Author
Owner

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

Note: The connection refused was because of fail2ban, my bad.

I still get this though after (successfully) logging in with authelia:

Image
@SamsiFPV commented on GitHub (Jul 9, 2025): Note: The connection refused was because of fail2ban, my bad. I still get this though after (successfully) logging in with authelia: <img width="1486" height="213" alt="Image" src="https://github.com/user-attachments/assets/aa6510dc-3616-433e-8b9e-a5b94175811d" />
Author
Owner

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

Image
@SamsiFPV commented on GitHub (Jul 9, 2025): <img width="915" height="833" alt="Image" src="https://github.com/user-attachments/assets/97b9e41d-d82d-4cc2-8107-599d29f6176d" />
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/audiobookshelf#3021
No description provided.