Server query connection closed when on localhost


I’m making a little windows service that watches a COD4 server and looks for each users team.
Then it auto changes that user on TS3 server to the right channel (it’s a private server where I play with some friends)

When I let my code run from my PC everything works so when a user changes teams my service changes that user to the right channel on teamspeak. Now when I run the same code on my server hosting the teamspeak server I always get following error:
custom_error: the command failed to execute: Connection closed
also when connecting to the teamspeak server (which happens on startup and everytime the client isn’t connected anymore) I get following lines in the teamspeak logs:

2020-05-14 13:18:17.168780|INFO    |VirtualServer |1  |query client connected 'Unknown'(id:2) from
2020-05-14 13:18:32.184433|INFO    |VirtualServerBase|1  |query client disconnected 'Unknown'(id:2) reason 'reasonmsg=deselected virtualserver'
2020-05-14 13:18:32.184433|INFO    |VirtualServer |1  |query client connected 'serveradmin'(id:1) from

and when I connect from my pc I get this

2020-05-14 14:00:20.717213|INFO    |VirtualServer |1  |query client connected 'serveradmin'(id:1) from

My query_ip_whitelist.txt looks like this:

So won’t it work from localhost but will from external ip?
B.T.W. I’m using the Splamy.TSLib for dotnet