I have a multisite installation of WordPress running on EC2 behind a load balancer (AWS ALB). The WP site URL is accessible through the load balancer only and the EC2 has no internet access. (below is not my real data)

  • site url : https://mysite.exmaple.com
  • private ip of EC2 hosting WP:
  • load balancer (site url CNAME points to this):myalb-account.region.elb.amazonaws.com. Its DNS resolution is,,

and this is my wp-config.php

define('WP_ALLOW_MULTISITE', true);
define('WP_SITEURL', 'https://mysite.exmaple.com/');
define('WP_HOME', 'https://mysite.exmaple.com/');
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
define( 'DOMAIN_CURRENT_SITE', 'mysite.exmaple.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

When I visit the site url mysite.exmaple.com, the main page loads correctly, but all other links/pages fail with 504 time out error returned by the load balancer. When I add a public IP to EC2 or activate NAT (i.e. allow EC2 to reach internet), everything works fine. I watched the network when loading pages and found that a connection is initiated to the load balancer (site url CNAME). Here are the logs.

$ netstat -nputw
tcp        0      1         SYN_SENT    - 

$ tcpdump -i any
03:39:13.350942 lo    In  IP localhost.domain > localhost.39562: 30122 4/0/1 CNAME myalb-account.region.elb.amazonaws.com., A, A, A (159)
03:39:16.670704 lo    In  IP localhost.domain > localhost.50067: 56611 4/0/1 CNAME myalb-account.region.elb.amazonaws.com., A, A, A (159)
03:39:38.616620 lo    In  IP localhost.domain > localhost.46720: 21504 4/0/1 CNAME myalb-account.region.elb.amazonaws.com., A, A, A (159)

I added the following to /etc/hosts of WordPress server to test. mysite.example.com subsite1.mysite.example.com

With that, all pages of all sites are loading without internet access.

Isn’t WordPress supposed to handle the domains/subdomains mapping internally and resolve to itself? Why is it trying to reach the site URL through internet ? Is this the normal behavior or something is missing/wrong with my configuration.

1 Answer 1


WordPress's behavior in this scenario is related to how it handles URL resolution and DNS lookup. WordPress relies on the site URL specified in its configuration to construct internal links and route requests. When you access your WordPress site at https://mysite.example.com, WordPress will generate links based on this URL.

In your case, you have configured your WordPress site URL as https://mysite.example.com in wp-config.php. When WordPress generates internal links, it will use this URL as the base.

The issue arises when you try to access other pages or subdomains within your WordPress multisite installation. WordPress will use the site URL https://mysite.example.com as the base, and when it constructs links to other pages or subdomains, it will use this URL. This means that when a user tries to access a subdomain or a different page, WordPress will construct URLs like https://mysite.example.com/other-page or https://subsite1.mysite.example.com, which are external to your EC2 instance.

Because your EC2 instance does not have internet access, it cannot resolve these external URLs, resulting in a timeout error.

To resolve this issue without giving your EC2 instance direct internet access, you can use the /etc/hosts file to override DNS resolution for these domains, just as you've already done: mysite.example.com subsite1.mysite.example.com

By adding these entries to /etc/hosts, you are telling the server to resolve these domain names locally, pointing them to the loopback address ( This allows WordPress to route requests internally without trying to reach external DNS servers.

  • Thank you @will-ashworth, yes, this is the behavior I'm seeing but I was expecting that requests initiated by WordPress will be resolved by some internal mechanism since it supports custom DNS specification. Thank you for confirming what is the default behavior.
    – Asmaa
    Commented Jan 21 at 1:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.