Redirect to new server IP address sends browser to different address

Trying to redirect browser when changing embedded web server from DHCP to fixed IP or fixed IP to DHCP (e.g., when changing SSIDs). I use the exact same function to generate the HTML for both. The fixed IP is 192.168.1.7 and the DHCP IP is 192.168.1.32.

When I switch from DHCP to fixed IP, the redirect works perfectly but when I go the other way the browser tries to load from 192.168.1.26, an unassigned DHCP address in the DHCP range, instead of 192.168.1.32

I captured the HTML for both cases from Chrome using Developer tools. This is the DHCP-to-fixed page that works:

<html><head>
<meta http-equiv="refresh" content="10;url=http://192.168.001.007/"> <title>'IP Mode Change'</title></head>
<body><h1>Server's new IP address is 192.168.001.007</h1>
<p>Click <a href="http://192.168.001.007">here</a> to redirect your browser to the new address.</p></body></html>

And this is the fixed-to-DHCP page that doesn't:

<html><head>
<meta http-equiv="refresh" content="10;url=http://192.168.001.032/"><title>'IP Mode Change'</title></head>
<body><h1>Server's new IP address is 192.168.001.032</h1>
<p>Click <a href="http://192.168.001.032">here</a> to redirect your browser to the new address.</p></body></html>

Here’s what Chrome says after this page runs:

This site can’t be reached 192.168.1.26 took too long to respond. Try: • Checking the connection • Checking the proxy and the firewall • Running Windows Network Diagnostics ERR_CONNECTION_TIMED_OUT

Remarkably, the manual link I added behaves the same way as the redirect. Firefox does the same thing, so it’s not just Chrome. The automatic redirect, link and FireFox all work fine for 192.168.1.7.

After the timeout I can type “192.168.001.032" into the browser address and the page I’m expecting loads just fine. I checked my router for any routes I may have manually entered involving that address, but there’s nothing.

I tried manually assigning a DHCP-range address of 192.168.1.44 to my server, in case my ASUSwrt-Merlin router firmware was doing something odd with the .32 address, but was redirected to 192.168.1.36.

I also tried using a 307 Temporary Redirect response instead of the tag and this behaved the same as well.

Any thoughts?