How to fix Digitalocean err connection refused Issue

Are you happy with your current hosting provider ?

The Digitalocean err connection refused issue might be caused by a firewall block or a missing log file.

Our Managed DigitalOcean Cloud Hosting Services provide assistance with a variety of these types of mistake inquiries.

See if we can’t come up with a workable solution to it today.

Digitalocean err_connection_refused

To take a picture, a client recently shut down the droplet. When he got to the website, he found the following:


As a first step, we look at the Digitalocean dashboard to see whether everything is powered on. In addition, we examine the boot messages in the Digitalocean console.

Next, we look into the Nginx service’s health:

# service nginx status

Restarting the Nginx service is also a possibility:

# service nginx restart

There are situations when we get the following error:

*Restarting nginx nginx [fail]

Use the following command to verify the Nginx configuration:

$ sudo nginx -t

Then we shall receive:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx [emerg] open() “/var/log/nginx/mysitename/access.log” failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed

The following are the most common contributing factors:

1. A firewall prevents the connection.

2. A service listening on localhost.

3. A missing log file.


  • Fill out a blank log file.

Root privileges are required to do this task.

# touch /var/log/nginx/mysitename/access.log

The intermediate directory will be missing if it fails.

Nginx has access to new and changed ownership and permissions:

# mkdir -p /var/log/nginx/mysitename

The chown and chmod commands are used to ensure that the right user has access to the files.

  • Use curl or wget to see whether the site can be accessed from the server.

Ports 80 and 443 must be opened in the firewall. In the Nginx configuration file, we also set it.

Initially, we verify the condition of port 443 in the server using the netstat command:

netstat -plan | grep :443

We opened port 443 on the firewall when we discovered it was blocked. To open a port, various firewalls use a different approaches.

For example, we may use the following syntax in iptables to open port 443:

iptables -A INPUT -p tcp –dport 443 -j ACCEPT

Similar to this, we may use: to open a port in firewalld on a CentOS server:

firewall-cmd –permanent –zone=public –add-port=443/tcp

/etc/nginx/nginx.conf is edited to include the following:

listen 443 ssl http/2 default_server;
listen [::]:80 default_server;

It will allow HTTPS connections by adding port 443 to the Nginx server’s listening port.

Finally, here is what port 443 will look like when Nginx is listening for traffic:

[root@xxx ~]# netstat -lpan | grep :443
tcp 0 0 1xx.2x.111.23:443* LISTEN 11978/nginx
tcp 0 0 1xx.2x.111.22:443* LISTEN 11978/nginx
tcp 0 0 1xx.2x.111.19:443* LISTEN 11978/nginx

Instead of, we make sure that the service listens on 0.0,0 (localhost). Setting it in the nginx.conf file is an option.