restAPI localhost connection

Hello guys!
I’m trying to realise a user-creation with php, so far the restAPI works but i wanted to be able to
limit the access to the localhost. When i use my public server adress it works but as soon as i use it with
localhost or 127.0.0.1 i get a connection refused. i’m using gizzle, but also tried it with curl over ssh where i also get a simple connection refused (127.0.0.1:port).
does anybody have an idea how i could fix it? help would be appreciated =)
thanks in advance!

Hello @calarocker ,
I am also trying but not get any solution than
i use

GitHub - gnello/php-openfire-restapi: A complete PHP client for the Openfire REST API Plugin.
for rest api as well as create user…