question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sorry for the issue spam… This time, I’ve done a decent amount of research and haven’t found any answer. Now that I’ve installed PowerDNS-Admin and everything appears to be running, when I go to powerdns.domain.com, I’m receiving a 502 error. This error is in /var/log/nginx/powerdns-admin.local.error.log:

cat /var/log/nginx/powerdns-admin.local.error.log 
2020/02/05 05:31:07 [crit] 2680#2680: *1 connect() to unix:/opt/web/powerdns-admin/powerdns-admin.sock failed (2: No such file or directory) while connecting to upstream, client: 10.9.0.241, server: powerdns.domain.com, request: "GET / HTTP/1.1", upstream: "http://unix:/opt/web/powerdns-admin/powerdns-admin.sock:/", host: "powerdns.domain.com"

I’m assuming this might be because on another guide I had to follow to get even this far, I was told to disable /etc/resolv.conf. After every command, I was receiving an error about not being able to resolve powerdns (hostname of the server). I added it back and set the nameserver back to 127.0.0.1 with option edns0.

cat /etc/hosts

127.0.0.1	localhost.localdomain	localhost
::1		localhost6.localdomain6	localhost6

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
### The following lines, Josh entered
127.0.0.1	powerdns.domain.com	powerdns
127.0.0.1	pdns.domain.com		pdns

Nginx Config:

server {
  listen *:80;
#  server_name               powerdns-admin.example.com www.powerdns-admin.example.com;
  server_name               powerdns.domain.com www.powerdns.domain.com;
  index                     index.html index.htm index.php;
  root                      /opt/web/powerdns-admin;
  access_log                /var/log/nginx/powerdns-admin.local.access.log combined;
  error_log                 /var/log/nginx/powerdns-admin.local.error.log;

  client_max_body_size              10m;
  client_body_buffer_size           128k;
  proxy_redirect                    off;
  proxy_connect_timeout             90;
  proxy_send_timeout                90;
  proxy_read_timeout                90;
  proxy_buffers                     32 4k;
  proxy_buffer_size                 8k;
  proxy_set_header                  Host $host;
  proxy_set_header                  X-Real-IP $remote_addr;
  proxy_set_header                  X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_headers_hash_bucket_size    64;

  location ~ ^/static/  {
    include  /etc/nginx/mime.types;
    root /opt/web/powerdns-admin/app;

    location ~*  \.(jpg|jpeg|png|gif)$ {
      expires 365d;
    }

    location ~* ^.+.(css|js)$ {
      expires 7d;
    }
  }

  location / {
    proxy_pass            http://unix:/opt/web/powerdns-admin/powerdns-admin.sock;
    proxy_read_timeout    120;
    proxy_connect_timeout 120;
    proxy_redirect        off;
  }
}

Thoughts? I’m finally so close to having this up and running… If it means anything, on my client machine, I modified the hosts file to point to the server’s IP using it’s hostname. I currently don’t have an internal DNS server. Going to the server’s IP address brings up the default Nginx web page.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Grommorcommented, Jul 22, 2020

@joshbgosh10592 Hi I encountered a similar problem, solved when I put the nginx config and official documentation ( see close to proxy_pass directive ) https://github.com/ngoduykhanh/PowerDNS-Admin/wiki/Running-PowerDNS-Admin-on-Ubuntu-or-Debian But I encountered another error PermissionError: [Errno 13] Permission denied: '/opt/web/powerdns-admin/powerdnsadmin/static/.webasset

helped crutch in the form of chmod 777 in the powerdnsadmin folder, maybe who knows the answer why this happens

2reactions
Mandarnoldcommented, May 27, 2021

Hi, I had the same issue in nginx error.log -> “upstream prematurely closed connection while reading response header from upstream”. In the howtoforge - tutorial for installing powerdns-admin there is a step to change permissions on the application root directory to user www-data. And after configure the systemd service there is a step to change the permissions on the sub-directory <root-path>/powerdnsadmin to user: pdns. It’s important to do these steps in the right order, otherwise you’ll get the upstream-error from nginx.

Read more comments on GitHub >

github_iconTop Results From Across the Web

502 bad gateway in Nginx: Top 5 reasons for it, & how to resolve
502 Bad Gateway Nginx commonly occurs when Nginx runs as a reverse proxy, and is unable to connect to backend services.
Read more >
How To Fix '502 Bad Gateway' Error In Nginx | LinuxHostSupport
The 502 Bad Gateway error is an HTTP status code that means that one server received an invalid response from another server.
Read more >
NGINX 502 Bad Gateway: PHP-FPM - Datadog
NGINX will return a 502 Bad Gateway error if it can't successfully proxy a request to PHP-FPM, or if PHP-FPM fails to respond....
Read more >
How to Fix NGINX 502 Errors Now! - Adam the Automator
Another common cause of NGINX 502 errors is when the PHP-FPM service is down on a reachable server. For this tutorial, you'll kill...
Read more >
How Do I Fix 502 Bad Gateway Nginx? - Linux Hint
Like every other web server, Nginx is also prone to certain errors, out of which the most common one is the 502 Bad...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found