keepcalculator

06 Numbers and Powers

Why Deploy Went to Wrong URL? Fixes

Card No. 06·15304 · Updated · Standard formula, shown below

Your successful deploy went to the wrong URL because the deployment target (server, container, or static host) was misconfigured, the wrong environment variable or branch was used, or a caching layer served an old or different version. This is rarely a code problem—it is almost always a mismatch between what you think you deployed and where the platform actually sent it. Below we break down the most common causes and how to fix them.

Background: How Deployments Get Routed

When you run a deploy, your code is built and uploaded to a specific destination. That destination is determined by a chain of settings: the repository or project you selected, the branch or tag that triggered the build, the environment (staging, production) tied to that branch, and the domain or subdomain mapped to that environment. If any link in that chain is off, your new code lands somewhere unexpected.

For example, on many platforms (like Netlify, Vercel, or GitHub Pages), each project has a default domain and you can add custom domains. If you deploy to the wrong project, you get the wrong URL. If you deploy a branch that is not linked to your production domain, the build may go to a preview URL instead. Even on self-hosted servers, the deploy script might copy files to the wrong directory or the web server (Nginx, Apache) might point to a different folder.

How to Diagnose the Mismatch

Before changing anything, gather evidence. Open the deploy log from your CI/CD tool (GitHub Actions, GitLab CI, Jenkins) or hosting dashboard. Look for the exact URL that was generated or the server IP and path that received the files. Then compare it to the URL you expected.

Common diagnostic steps:

  • Check the deploy log for the output URL or server address.
  • Look at the environment variables used during the build—especially BASE_URL, PUBLIC_URL, or API_URL—they may point to a different domain.
  • Verify the branch that triggered the deploy. If you pushed to develop, it may deploy to a staging URL, not production.
  • Inspect the DNS records for your custom domain—maybe the A record or CNAME points to the wrong host.

Once you know where it went, you can correct the configuration.

Common Causes and Their Fixes

Here are the most frequent reasons a deploy ends up at the wrong URL, with concrete solutions.

1. Wrong Project or Repository Selected

If you use a CI/CD service connected to your Git host, you might have multiple projects with similar names. A deploy triggered from the wrong repo will go to that repo’s URL. Fix: double-check the repo name in the deploy trigger and the hosting dashboard.

2. Branch-to-Environment Mapping Is Off

Many platforms let you link a branch (e.g., main) to a production environment and another (e.g., staging) to a preview URL. If you accidentally push to the wrong branch, or the mapping is misconfigured, your code goes to the wrong place. Fix: review the environment settings in your hosting provider and ensure the branch you push to matches the intended environment.

3. Caching or CDN Serving Old Content

Your deploy may have succeeded, but a CDN (like Cloudflare) or browser cache still shows the old version from a different URL. This is especially common when you have multiple domains pointing to the same site. Fix: purge the CDN cache and hard-refresh your browser. Also check that the domain you are visiting actually points to the same project.

4. Environment Variables Pointing Elsewhere

If your app reads a BASE_URL or API_URL from environment variables, and those variables are set to a different domain (e.g., a staging API), your frontend may load but make requests to the wrong URL. Fix: update the environment variables for the correct environment and redeploy.

5. Web Server Root Directory Misconfigured

On a VPS or shared host, your deploy script may upload files to /var/www/html while the web server serves from /var/www/site. Fix: check the document root in your server config (e.g., Nginx server block or Apache DocumentRoot) and align it with your deploy path.

How to Prevent It Next Time

Set up guardrails so a wrong-URL deploy is less likely:

  • Use distinct subdomains for staging and production (e.g., staging.example.com vs example.com).
  • Add a deploy protection rule that requires manual approval for production deploys.
  • Pin your environment variables per environment—never share a single set across staging and production.
  • Automate a post-deploy smoke test that checks the live URL returns the expected content.
  • Keep a deployment checklist that includes verifying the target URL before and after the deploy.

Comparing Platforms: Static Hosts vs. Servers

The exact cause often depends on where you host.

Static hosts (Netlify, Vercel, GitHub Pages): these platforms tie deploys to a Git branch and generate a unique URL per deploy. If you push to a branch that is not the default, you get a preview URL. Also, each project has a default domain (e.g., project-name.netlify.app). If you have multiple projects, you might be looking at the wrong one. Fix: check the project name in the URL and the branch in the deploy log.

Self-managed servers (VPS, Docker): here the problem is often the deploy script. It might copy files to the wrong directory, or the container might be mapped to the wrong port. For Docker, a common issue is port mapping: your container runs on port 3000 but the reverse proxy sends traffic to port 80. Fix: inspect your docker-compose.yml or Nginx config for the correct port and path.

Frequently Asked Questions

Why does my deploy log say success but the site still shows old content?

This is usually caching. Your browser, a CDN, or the hosting provider’s cache may be serving a stale copy. Try a hard refresh (Ctrl+Shift+R), purge the CDN cache, or append a query string to the URL (e.g., ?v=2) to bypass cache. If that doesn’t work, check that the deploy actually went to the same project/domain you are viewing.

What if I deployed to the wrong branch?

If you pushed to staging but meant to deploy main, you can trigger a new deploy from the correct branch. Most platforms allow you to redeploy from the dashboard by selecting the branch. Alternatively, merge the changes into the correct branch and push again.

How do I find the exact URL my deploy went to?

Look in the deploy log—most platforms print the URL after the build finishes. For example, on Netlify it says “Website URL: https://xxxx.netlify.app�. On a self-hosted server, check the deploy script output for the server IP and path. If you can’t find it, check the DNS records for your domain to see where they point.

Can multiple domains cause a wrong-URL deploy?

Yes. If you have several domains pointing to the same project, your deploy may be successful but you might be visiting a domain that isn’t linked to that project. Check the hosting dashboard to see which domains are attached to which project and ensure your custom domain is correctly mapped.

Is it possible that my build process itself is the problem?

Sometimes. If your build script generates a baseUrl or publicPath based on an environment variable, and that variable is wrong, the built files may reference the wrong domain. Check your build configuration (e.g., vite.config.js, next.config.js) and the environment variables used during the build.

Final Thoughts

Wrong-URL deploys are almost always configuration issues, not code bugs. By systematically checking the deploy log, branch mapping, environment variables, and caching, you can quickly identify where the mismatch occurred. Once you fix the root cause, add a simple verification step to your workflow—like a script that curls the expected URL and checks for a unique string—so you catch it instantly next time.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →