title: Strapi - Axios request on SSR fails with "connect ECONNREFUSED", but CSR works well
body: <p>Request to Strapi during SSR fails for an unknown reason <strong>only during SSR</strong>. The SSR request hits the Strapi endpoint, I can see the data about to be returned. But something happens and the request fails.</p>
  <pre><code>err :&gt;&gt;  AxiosError: connect ECONNREFUSED ::1:1337
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) {
    port: 1337,
    address: '::1',
    syscall: 'connect',
    code: 'ECONNREFUSED',
    errno: -4078,
    config: {
      transitional: {
        silentJSONParsing: true,
        forcedJSONParsing: true,
        clarifyTimeoutError: false
      },
      adapter: [Function: httpAdapter],
      transformRequest: [ [Function: transformRequest] ],
      transformResponse: [ [Function: transformResponse] ],
      timeout: 0,
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      env: { FormData: [Function] },
      validateStatus: [Function: validateStatus],
      headers: {
        Accept: 'application/json, text/plain, */*',
        'User-Agent': 'axios/0.27.2'
      },
      baseURL: 'http://localhost:1337',
      url: '/api/reviews',
      params: { locale: undefined, populate: '*', sort: 'createdAt:desc' },     
      method: 'get',
      data: undefined
    },
    request: &lt;ref *1&gt; Writable {
      _writableState: WritableState {
        objectMode: false,
        highWaterMark: 16384,
        finalCalled: false,
        needDrain: false,
        ending: false,
        ended: false,
        finished: false,
        destroyed: false,
        decodeStrings: true,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: true,
        bufferProcessing: false,
        onwrite: [Function: bound onwrite],
        writecb: null,
        writelen: 0,
        afterWriteTickInfo: null,
        buffered: [],
        bufferedIndex: 0,
        allBuffers: true,
        allNoop: true,
        pendingcb: 0,
        constructed: true,
        prefinished: false,
        errorEmitted: false,
        emitClose: true,
        autoDestroy: true,
        errored: null,
        closed: false,
        closeEmitted: false,
        [Symbol(kOnFinished)]: []
      },
      _events: [Object: null prototype] {
        response: [Function: handleResponse],
        error: [Function: handleRequestError],
        socket: [Function: handleRequestSocket]
      },
      _eventsCount: 3,
      _maxListeners: undefined,
      _options: {
        maxRedirects: 21,
        maxBodyLength: 10485760,
        protocol: 'http:',
        path: '/api/reviews?populate=*&amp;sort=createdAt:desc',
        method: 'GET',
        headers: [Object],
        agent: undefined,
        agents: [Object],
        auth: undefined,
        hostname: 'localhost',
        port: '1337',
        nativeProtocols: [Object],
        pathname: '/api/reviews',
        search: '?populate=*&amp;sort=createdAt:desc'
      },
      _ended: true,
      _ending: true,
      _redirectCount: 0,
      _redirects: [],
      _requestBodyLength: 0,
      _requestBodyBuffers: [],
      _onNativeResponse: [Function (anonymous)],
      _currentRequest: ClientRequest {
        _events: [Object: null prototype],
        _eventsCount: 7,
        _maxListeners: undefined,
        outputData: [],
        outputSize: 0,
        writable: true,
        destroyed: false,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        maxRequestsOnConnectionReached: false,
        _defaultKeepAlive: true,
        useChunkedEncodingByDefault: false,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: 0,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        _closed: false,
        socket: [Socket],
        _header: 'GET /api/reviews?populate=*&amp;sort=createdAt:desc HTTP/1.1\r\n' 
  +
          'Accept: application/json, text/plain, */*\r\n' +
          'User-Agent: axios/0.27.2\r\n' +
          'Host: localhost:1337\r\n' +
          'Connection: close\r\n' +
          '\r\n',
        _keepAliveTimeout: 0,
        _onPendingData: [Function: nop],
        agent: [Agent],
        socketPath: undefined,
        method: 'GET',
        maxHeaderSize: undefined,
        insecureHTTPParser: undefined,
        path: '/api/reviews?populate=*&amp;sort=createdAt:desc',
        _ended: false,
        res: null,
        aborted: false,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        reusedSocket: false,
        host: 'localhost',
        protocol: 'http:',
        _redirectable: [Circular *1],
        [Symbol(kCapture)]: false,
        [Symbol(kNeedDrain)]: false,
        [Symbol(corked)]: 0,
        [Symbol(kOutHeaders)]: [Object: null prototype]
      },
      _currentUrl: 'http://localhost:1337/api/reviews?populate=*&amp;sort=createdAt:desc',
      [Symbol(kCapture)]: false
    }
  }
  </code></pre>
  <p>The request is performed like this:</p>
  <pre><code>import { API_URL } from '../config';
  import { isJsonString } from '../utils/cookie';
  import axios from &quot;axios&quot;
  
  export async function GET(ctx) {
    const { params } = ctx
    const { lang } = params
  
    try {
      const result = await axios({
        baseURL: API_URL,
        url: '/api/reviews',
        params: {
          locale: lang,
          populate: '*',
          sort: 'createdAt:desc'
        }
      })
      console.log('result :&gt;&gt; ', result);
  
      return {
        status: 200,
        body: result.data,
      }
    } catch (err: any) {
      console.log('err :&gt;&gt; ', err);
      return {
        status: 500,
        body: {
          error:
            isJsonString(err.response?.data) || typeof err.response?.data === &quot;object&quot;
              ? err.response?.data
              : &quot;DB Error&quot;,
        },
      }
    }
  }
  </code></pre>
  <p>What could possibly be a reason for this? Maybe it doesn't like headers or smth?</p>