"[Errno 111] Connection refused" when using platform.api.get()


#1

I have an issue with using server side scripting. When I try to access the API in the script, I get an [Errno 111] Connection refused message. I’ve tried several API endpoints and get the same message. I did this as an admin, so I should have access. I’m running the docker image. The script and the complete message is below. Any ideas about what’s wrong?

Script: http://pastebin.com/KEnhdnNG
Error: http://pastebin.com/hrNLz5Gc


#2

@magnus-stng Can you tell me first does the user have a role assigned that has script access enabled? I’ll need to verify but I’m not sure if the user table can be scripted on. I’ll post back, in the meantime check script access is enabled.


#3

@magnus-stng following up, you can script on the system/user.


#4

@mattschaer To clarify: I tested the script as an admin, so I have full access to everything. Additionally, I tested using several other API endpoints, such as “system/user”, nothing, and even the same endpoint as the script is run on (in this case a specific table), and I still get the same message.


#5

I discovered that the error was caused by port forwarding. Since I use Vagrant and Docker, I forward port 5000 (host) to 80 (DreamFactory). Then when I do API requests on localhost:5000, the script fails to do API requests internally.

I think this is because the script also tries to do the request on localhost:5000, while it needs to do it on localhost, because of the forwarded port. I have a working workaround that somewhat confirms this issue: http://pastebin.com/D1rDQRQr

Is this how it is supposed to work, or is it a bug? Can I change this behavior? I would like to not have to use workarounds.