How to redirect a sub-domain to a different droplet?

I had one droplet and a domain.

  • Droplet:,
  • Domain:

I rebuilt the existing Droplet and added a new one.

Now I have two droplets and a domain.

  • Droplet-1:,
  • Droplet-2:,
  • Domain:

I added four ‘A’ DNS records:,,,

When I try to generate a letsencrypt certificate on Droplet-2, I get the following error:

pontresadmin@pontres-main:~$ sudo certbot --nginx -d -d
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for and

Certbot failed to authenticate some domains (authenticator: nginx). The Certificate Authority reported these problems:
  Type:   connection
  Detail: Fetching Connection refused

  Type:   connection
  Detail: Fetching Connection refused

Hint: The Certificate Authority failed to verify the temporary nginx configuration changes made by Certbot. Ensure the listed domains point to this nginx server and that it is accessible from the internet.

When I perform a DNS lookup using and, both points to the Droplet-2 IP.

I want the traffic for to be redirected to Droplet-2 and to be redirected to Droplet-1.

What am I doing wrong?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
June 28, 2023

Hi there,

It looks like the certificate issue could be due to Nginx not being configured correctly or not running on your Droplet-2. It is crucial to make sure that your Nginx server is correctly set up and running before attempting to generate SSL certificates using Certbot.

Before you proceed, double-check your DNS records. Here’s how they should be:

  • A record pointing to the IP of Droplet-2 (
  • A record pointing to the IP of Droplet-2 (
  • A record pointing to the IP of Droplet-1 (
  • A record pointing to the IP of Droplet-1 (

When you attempt to generate the certificate on Droplet-2, use the -d flag to specify the domain(s) you want the certificate for:

sudo certbot --nginx -d -d

This is telling Certbot that you want a certificate for and It will try to validate that you own these domains by making a request to them. This request must hit your server (Droplet-2) for validation to succeed.

If the requests can’t reach your server, you’ll see the “connection refused” error that you’re seeing now. Make sure Nginx is running and properly configured to respond to requests for and

You can verify if Nginx is running with:

sudo systemctl status nginx

Also, check your Nginx server block configuration for and and make sure it’s correct. It should be something like:

server {
    listen 80;

    location / {
        proxy_pass http://localhost:8000;  # Replace with actual configuration
        # ...

    # ...

This configuration should be in a file in /etc/nginx/sites-available/, and there should be a symbolic link to that file in /etc/nginx/sites-enabled/.

If your Nginx setup is correct and you’re still having issues, there might be a firewall blocking incoming connections. If you’re using UFW, you can check the status with sudo ufw status verbose and make sure it’s allowing incoming connections on ports 80 and 443.

Let me know how it goes!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel