title: Mock Service Worker Error occurred while trying to proxy request
body: <p>I am using MSW for my React app and am getting the following error when trying to run in mock mode;
  Error occurred while trying to proxy request /api/myApi from localhost:3000 to { port: 8080 } (ECONNREFUSED) (<a href="https://nodejs.org/api/errors.html#errors_common_system_errors" rel="nofollow noreferrer">https://nodejs.org/api/errors.html#errors_common_system_errors</a>)
  I am trying to use both for testing and as dev api server (mock data)</p>
  <p>Not sure if there is additional config needed for proxying the request when running in mock mode.</p>
  <p>Below is my command in package.json</p>
  <pre><code>&quot;start:mock&quot;: &quot;cross-env NODE_ENV=mock webpack serve --progress --config config/webpack.local.js&quot;,
  </code></pre>
  <p>Below is the code in src/index.js</p>
  <pre><code>import * as serviceWorker from './serviceWorker';
  
  if (process.env.NODE_ENV === 'mock') {
    const { worker } = require('./browser')
    worker.start()
  }
  </code></pre>
  <p>//src/browser.js</p>
  <pre><code>import { setupWorker } from 'msw'
  import { handlers } from './testServer'
  // This configures a Service Worker with the given request handlers.
  export const worker = setupWorker(...handlers)
  </code></pre>
  <p>Below is src/testServer.js</p>
  <pre><code>import &quot;whatwg-fetch&quot;;
  import { rest } from &quot;msw&quot;;
  import { setupServer } from &quot;msw/node&quot;;
  
  import data from &quot;./data&quot;;
  
  const handlers = [
    rest.get(&quot;http://localhost/api/myApi&quot;, (req, res, ctx) =&gt; {
      return res(ctx.status(200), ctx.json(data));
    })
  ];
  
  
  // This configures a request mocking server with the given request handlers.
  const server = setupServer(...handlers);
  
  beforeAll(() =&gt; server.listen());
  afterAll(() =&gt; server.close());
  afterEach(() =&gt; server.resetHandlers());
  
  export { server, rest, handlers};
  </code></pre>