[HPM] Error occurred while proxying request localhost:3000/favicon.ico to http://krullend.localhost/ [ECONNREFUSED]

I did a fresh install of Bedrock and Sage 10. “yarn build” works without warnings or errors. But when running “yarn dev” the server url throws “Error occurred while trying to proxy: localhost:3000/”. The proxy url does work. Any idea how to fix this? I’m running it on Mac os X.

my bud.config.js:

/**
 * @typedef {import('@roots/bud').Bud} bud
 *
 * @param {bud} app
 */
module.exports = async (app) => {
  app
    /**
     * Application entrypoints
     *
     * Paths are relative to your resources directory
     */
    .entry({
      app: ['@scripts/app', '@styles/app'],
      editor: ['@scripts/editor', '@styles/editor'],
    })

    /**
     * These files should be processed as part of the build
     * even if they are not explicitly imported in application assets.
     */
    .assets('images')

    /**
     * These files will trigger a full page reload
     * when modified.
     */
    .watch('resources/views/**/*', 'app/**/*')

    /**
     * Target URL to be proxied by the dev server.
     *
     * This should be the URL you use to visit your local development server.
     */
    .proxy('http://krullend.localhost')

    /**
     * Development URL to be used in the browser.
     */
    .serve('http://localhost:3000');
};
1 Like

i have the identical problem

1 Like

Same problem on a project I was working on yesterday. All I did was trellis down and reboot my computer. Have not run any updates. Site is accessible at the dev url. Was using dev-main.

[proxy] › ✘  error     [HPM] Error occurred while proxying request localhost:3000/ to http://mysite.test/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)

I tried the following to no avail:

  • Deleting node_modules, vendor, .budfiles, public, yarn.lock and then running composer install and yarn again
  • Different ports: 3000, 4444, 8000, 8888
  • Removed .serve() from bud config to let it decide, it always picks port 3000
  • Was running https on local, I set ssl to false in trellis, and redid the whole vm.
  • Tried a fresh composer create-project roots/sage your-theme-name, edited bud with the dev url, activated the theme, and ran yarn and yarn dev (so this is 10.3.0)
  • Fresh wp database
  • Checked for conflicting IPs in /etc/hosts
  • version 6.4.4 of @roots/bud, @roots/bud-sass and @roots/sage
  • version 6.4.3 of @roots/bud, @roots/bud-sass and @roots/sage
  • version 6.4.0 of @roots/bud, @roots/bud-sass and @roots/sage
  • started dnsmasq.service
  • trellis check succeeds

nodejs.org says this about the error: ECONNREFUSED (Connection refused): No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host.
So, there’s some reason it can’t reach it. I am not running any firewalls.

Running netstat -tunlp shows my port listed only under tcp6.

In my /etc/hosts file, trellis/vagrant inserts an additional record only when it is live (whereas the 192.168.56.x record stays). That record looks like this:
127.0.0.1 sub.site.test # VAGRANT xxxxxxxxxxxxxx (default) / xxxxxxx-xxxxx-xxxx-xx-xxxxxxx
When i commented that record out I was able to successfully load localhost:3000 - however, it has no styling.

system

  • arch linux, btw.
  • node 16.4.0
  • yarn 1.22.19
  • npm 8.3.1

Ok, the no styling had to do with me not specifying localhost. (while testing i was using just .serve(8000) ). So, I know now to use the full: .serve("http://localhost:8000")

So the only question that remains is, why is vagrant/trellis adding this additional 127.0.0.1 record to /etc/hosts which causes bud to fail?

Solved: I had installed the vagrant plugin, vagrant-hostsupdater, after uninstalling it no longer adds the extra 127.0.0.1 record. So, the reboot must have put that install into effect.

That was a nice couple of hours I wasted. Thank you all for reading and have a great weekend.

1 Like

Thanks for sharing your solution, @erit . It helped me a lot. :+1:t3:

1 Like