[GH-ISSUE #75] API Error: 0 #41

Closed
opened 2026-02-28 01:20:42 +03:00 by kerem · 9 comments
Owner

Originally created by @skfigved on GitHub (Jan 20, 2016).
Original GitHub issue: https://github.com/tuxis-ie/nsedit/issues/75

Been trying to get this to work now with multiple linux distro and powerdns versions. Currently 3.4.7 but always get this message

Are there currently any issues with powerdns 3.4.7 and nsedit?

Originally created by @skfigved on GitHub (Jan 20, 2016). Original GitHub issue: https://github.com/tuxis-ie/nsedit/issues/75 Been trying to get this to work now with multiple linux distro and powerdns versions. Currently 3.4.7 but always get this message Are there currently any issues with powerdns 3.4.7 and nsedit?
kerem closed this issue 2026-02-28 01:20:42 +03:00
Author
Owner

@tuxis-ie commented on GitHub (Jan 20, 2016):

Looks like there is an issue with Curl? The error seems to come from https://github.com/tuxis-ie/nsedit/blob/master/zones.php#L80

You should be able to change that line to:

jtable_respond(null, 'error', "API Error: $code ".curl_error($ch));

Does that clarify anything?

<!-- gh-comment-id:173124221 --> @tuxis-ie commented on GitHub (Jan 20, 2016): Looks like there is an issue with Curl? The error seems to come from https://github.com/tuxis-ie/nsedit/blob/master/zones.php#L80 You should be able to change that line to: ``` jtable_respond(null, 'error', "API Error: $code ".curl_error($ch)); ``` Does that clarify anything?
Author
Owner

@skfigved commented on GitHub (Jan 20, 2016):

Now im getting following message "API Error: 0 Failed to connect to 127.0.0.1: Permission denied"
Doing a curl from localhost works both getting zone list and adding zones

curl -X POST --data '{"name":"example.org", "kind": "Native", "masters": [], "nameservers": ["ns1.example.org", "ns2.example.org"]}' -v -H 'X-API-Key: 12345' http://127.0.0.1:8081/servers

curl -H 'X-API-Key: 12345' http://127.0.0.1:8081/servers/localhost/zones

<!-- gh-comment-id:173135298 --> @skfigved commented on GitHub (Jan 20, 2016): Now im getting following message "API Error: 0 Failed to connect to 127.0.0.1: Permission denied" Doing a curl from localhost works both getting zone list and adding zones curl -X POST --data '{"name":"example.org", "kind": "Native", "masters": [], "nameservers": ["ns1.example.org", "ns2.example.org"]}' -v -H 'X-API-Key: 12345' http://127.0.0.1:8081/servers curl -H 'X-API-Key: 12345' http://127.0.0.1:8081/servers/localhost/zones
Author
Owner

@tuxis-ie commented on GitHub (Jan 20, 2016):

Ok. Can you paste your config here?

<!-- gh-comment-id:173137924 --> @tuxis-ie commented on GitHub (Jan 20, 2016): Ok. Can you paste your config here?
Author
Owner

@skfigved commented on GitHub (Jan 20, 2016):

This is the config from config.inc.php.

<!-- gh-comment-id:173143045 --> @skfigved commented on GitHub (Jan 20, 2016): This is the config from config.inc.php. <?php $apiuser = ''; # The PowerDNS API username. Leave empty for authmethod='xapikey' (see AUTHENTICATION) $apipass = '12345'; # The PowerDNS API-user password or the PowerDNS-API key (see AUTHENTICATION) $apiip = '127.0.0.1'; # The IP of the PowerDNS API $apiport = '8081'; # The port of the PowerDNS API $apivers = 0; # The version of the PowerDNS API. 0 == experimental, 1 = v1 (pdns 4.0) $apisid = 'localhost'; # PowerDNS's :server_id $apiproto = 'http'; # http | https $apisslverify = FALSE; # Verify SSL Certificate if using https for apiproto $allowzoneadd = FALSE; # Allow normal users to add zones
Author
Owner

@tuxis-ie commented on GitHub (Jan 20, 2016):

I'm missing $authmethod, which should be set to 'xapikey'...

<!-- gh-comment-id:173143684 --> @tuxis-ie commented on GitHub (Jan 20, 2016): I'm missing $authmethod, which should be set to 'xapikey'...
Author
Owner

@skfigved commented on GitHub (Jan 20, 2016):

here is the rest

$authmethod = 'xapikey';

<!-- gh-comment-id:173143804 --> @skfigved commented on GitHub (Jan 20, 2016): here is the rest $authmethod = 'xapikey';
Author
Owner

@skfigved commented on GitHub (Jan 20, 2016):

Just noticed that the api error message does not include the port number if this by any chance is related

API Error: 0 Failed to connect to 127.0.0.1: Permission denied

Shouldt it say something like 127.0.0.1:8081 ?

<!-- gh-comment-id:173144982 --> @skfigved commented on GitHub (Jan 20, 2016): Just noticed that the api error message does not include the port number if this by any chance is related API Error: 0 Failed to connect to 127.0.0.1: Permission denied Shouldt it say something like 127.0.0.1:8081 ?
Author
Owner

@skfigved commented on GitHub (Jan 20, 2016):

The permission denied got me on the right track. It never were anything with powerdns or nsedit config. It was actually SElinux not permitting httpd to make network connections.

My case was solved with this command
setsebool -P httpd_can_network_connect 1

Running Centos 7
Thanks for assisting me getting this solvet

<!-- gh-comment-id:173190587 --> @skfigved commented on GitHub (Jan 20, 2016): The permission denied got me on the right track. It never were anything with powerdns or nsedit config. It was actually SElinux not permitting httpd to make network connections. My case was solved with this command setsebool -P httpd_can_network_connect 1 Running Centos 7 Thanks for assisting me getting this solvet
Author
Owner

@tuxis-ie commented on GitHub (Jan 20, 2016):

Haha. Thanks for letting us know! Always good to have these kinds of commands in an archive somewhere.

<!-- gh-comment-id:173190847 --> @tuxis-ie commented on GitHub (Jan 20, 2016): Haha. Thanks for letting us know! Always good to have these kinds of commands in an archive somewhere.
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/nsedit#41
No description provided.