Rails 5 application(nginx/puma) with Subdomain is not working even after adding the A Records.

Posted February 6, 2020 2.9k views
Ruby on RailsNginx

I have recently setup the main domain, for example… droplet) on rails 5 and it got deployed and live successfully.
Now I want to use, which is an distinct application(added new droplet) using the same domain name and hence i have also added required entries in the Domain setting as shown below.
I have just renamed my subdomain and domain to default names -

in settings - 2A RECORDS/3NS RECORDS

Hostname                 | Value
-------------            | -------------     | new_droplet_ip_subdomain               | droplet_ip_domain               | ns1,ns2,ns3 entires(rented from godaddy) 

also added …settings

(Type)Hostname                   | Value
-------------                    | -------------
(cname)*    |
(a record)             | droplet_ip_domain
3 ns records                     | ns1,ns2,ns3 entires(rented from godaddy) 

Moreover there is also a PTR record for -

IPADRESS              |  PTR Record    
sub_domain_ip_address | subdomain.domain.

MOrover, there is firewall open to all ports

Type    Protocol    Port Range  Sources 
SSH TCP 22  All IPv4 All IPv6   More 
HTTP    TCP 80  All IPv4 All IPv6   More 
HTTPS   TCP 443 All IPv4 All IPv6   More 
Custom  TCP 2812    All IPv4 All IPv6   More 

I am not able to understand why its still failing as I cannot see a single log generated in the subdomainserverip, where deployment is successful.I am sure, I am making some mistake in the DNS, but what is that.I have also referred DNS details for Digital Ocean but still when I hit on browser, it just keeps loading and stops saying that took too long to respond.

I already have successfully deployed and its working great.
1- do i need to update hosts file?..i did but still the same
2- when I ping - ping, it works and packets are received.
3- NO logs are generated on the server, when I login using ssh user@ip, nginx and puma is working and started, but no logs.
4- On the browser, when I hit, it get took too long to respond.

5- my /etc/nginx/sites-enabled/ file looks like shown below: –

upstream puma {
  server unix:///home/mike/apps/domain/shared/tmp/sockets/domain-puma.sock;

server {
  listen default deferred;

  root /home/mike/apps/domain/current/public;
  access_log /home/mike/apps/domain/current/log/nginx.access.log;
  error_log /home/mike/apps/domain/current/log/nginx.error.log info;

  location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;

  try_files $uri/index.html $uri @puma;
  location @puma {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;

    proxy_pass http://puma;

  error_page 500 502 503 504 /500.html;
  client_max_body_size 10M;
  keepalive_timeout 10;

Can somebody help or give me some ideas as what is missing.

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.

Submit an Answer
1 answer


If you ping your domain name and you get the IP of your Droplet, this means that your DNS is set up correctly.

I believe that the problem must be with the Nginx configuration.

You could try to do the following:

  • Make sure that Nginx is listening on port 80:
sudo netstat -plant | grep 80

Feel free to share the output here.

  • First run an Nginx config test:
sudo nginx -t
  • If you get a Status OK then try restarting Nginx to make sure that the latest changes that you’ve made are in place:
systemctl restart nginx
  • Finally make sure to check your Nginx error log as well, there should be more information regarding the problem with the timeout.

I would guess that it could be the listen directive that might be causing the problem for you. Can you, as a test, try to change it from:

  listen default deferred;


    listen 80 default deferred;

Basically that way if you run netstat again it would show you that nginx listens on which means that it will accept connections from any IP and you should be able to access the service remotely.

Let me know how it goes!

  • Hey Bobby,
    Thanks for the helping hand.However, there is no major change.Let me share the steps that I took after your message....

    – When I ping…

    PING ( 56(84) bytes of data.
    --- ping statistics ---
    79 packets transmitted, 0 received, 100% packet loss, time 79876ms

    – When I checked port 80

    mike@ICMS:~$ sudo netstat -plant | grep 80
    tcp        0      0    *               LISTEN      2079/nginx: master  
    tcp6       0      0 :::80     

    – sudo nginx -t - always returns OK, even if delete all links from sites-*/, it still gives OK.

    – I Updated nginx server block listen 80 default deferred;,
    still no changes.

    – Morever, my log/production.log…nginx.error.log…nginx.access.log..puma.access.log and puma.error.log are blank, since day one.

    Let me know if this was helpful and kindly guide me more.
    I have updated my dns settings..Sharing below - - WORKING
    DNS records
    Type    Hostname    Value   TTL (seconds)   
    * Copy    is an alias of 
    A    Copy  directs to
    A    Copy   directs to 
    NS   Copy   directs to 
    technast.comCopy    directs to   
    1800 Copy   More 
    technast.comCopy    directs to
    * Copy    is an alias of
    A    Copy  directs to
    NS Copy  directs to
    NS Copy  directs to
    NS Copy  directs to 
    • Hi @Milind1011,

      It looks like that when you ping the domain name you get 100% packet loss. This would make me think that either your A record might not be matching your Droplet’s IP address or that your firewall is blocking all of the traffic.

      What I could suggest first is to try and telnet on port 80 from your PC to your Droplet’s IP to make sure that the Nginx instance is actually reachable:

      telnet your_dropet_ip_address 80

      Also, I would recommend double-checking your DNS records and making sure that the A record for your subdomain matches the IP of your Droplet.

      One last suggestion would be, do not add your subdomain name as a separate domain name in your DigitalOcean Domain names control, but instead add the A record and the CNAME records for the subdomain name under your main domain’s DNS zone.

      Let me know how it goes!

      • Thanks Bobby, Due to some time contraint, I have decided to use the same domain to deploy the code.However, i will come back later to inquire about this issue again…and I am sure its something related to DNS settings, as you have mentioned.

        Once again..Thank you.