Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jconner's avatar

Laravel Forge subdomain not working

I'm trying to setup a new server that has both a live domain and a staging domain so I created a new Digital Ocean server, deleted the default site, added the production domain as a site and the staging domain which I'd like to be staging.example.com.

Then I added an A record pointing to the new server IP address. When I open terminal and run dig on the staging domain it's getting an answer back from the new server IP address but if I visit the url in the browser I get an "ERR_CONNECTION_TIMED_OUT" error.

I even tried setting up another testing subdomain with another domain on another server in forge and I'm having the same results.

What could be going on?

0 likes
10 replies
Wraith's avatar

Paste Virtual Server settings and .htaccess

jconner's avatar

I don't have an .htaccess file on this one. The site's Nginx Config file is below. I just replaced the actual domain with staging.domain.com.

# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/staging.domain.com/before/*;

server {
    listen 80;
    listen [::]:80;
    server_name staging.domain.com;
    root /home/forge/staging.domain.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

    ssl_protocols TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DO NOT REMOVE!)
    include forge-conf/staging.domain.com/server/*;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/staging.domain.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/staging.domain.com/after/*;
rodrigo.pedra's avatar

When you created your site through Forge did you select the "Allow Wildcard Sub-Domains" checkbox in the "New Site" form?

This checkbox tells forge to configure Nginx to accept any subdomains and send the requests to the Laravel application.

You'll still need to configure the CNAME records on your DNS provider to point o your server's IP.

I am not an expert on nginx configuration, but have used this option with success in projects that have subdomains.

I don't know how to add this option if you created your site without selecting this checkbox. If you can recreate your site through Forge, it might help.

1 like
cookie_good's avatar

for subdomains on DNS I always create an A record pointing the subdomain, for example

staging         A           server_ip_here

Then I create a virtual host for the subdomain. I'm on apache2 but I imagine nginx is similar, no?

jconner's avatar

I do have an A record setup at the domain pointing to the server IP address.

jconner's avatar

@rodrigo.pedra I didn't check the 'Allow wildcard sub-domains" at time of creation but I believe that I haven't done on other servers and there was no issue. Besides, I setup a second subdomain on this same server to another domain that I own with no issue at all.

Maybe I just need to destroy the server and start over?

rodrigo.pedra's avatar

Not the server just the sites.

  1. Go to the "Sites" dropdown menu on the navbar and select the site you want to remove
  2. After navigation scroll to the bottom an click the "delete" button and confirm
  3. Repeat for each subdomain (if you intend all subdomains to be handled by the same Laravel app)

After that go to the servers dropdown menu, select your server and add a new site checking that option.

Of course, if you tweaked a lot of nginx files and are not sure if you messed up something you can recreate the server. But recreating only the sites is faster than provisioning a new server.

Rhynixjohn's avatar

Hi @jconner did you find a solution to this. Am having the exact same issue. My subdomains are not working.

warpig's avatar

so you can't just check the option for "Allow Wildcard Sub-Domains" if the site was already created? one would need to re-create the site? is this the only way? when i created mine i did not checked this box.

Please or to participate in this conversation.