인프런 커뮤니티 질문&답변

Tony Moon님의 프로필 이미지

작성한 질문수

[리뉴얼] React로 NodeBird SNS 만들기

ECONNREFUSED 에러 질문입니다.

21.05.12 08:52 작성

·

2.2K

0

라우터 전부 있고 axios baseUrl = http://localhost:3065 로 했는데 프론트서버 킬때 웹페이지 화면은 나오는데 ECONNREFUSED 에러가 뜨네요. 이 에러의 원인은 무엇인가요? (LOAD_MY_INFO_FAILURE, LOAD_POSTS_FAILURE 액션에서 data undifined error가 나와서 둘다 액션을 error: err.name으로 바꿨습니다. name으로 안하면 data undefined error만 나오더라구요.) 아 그리고 백서버도 켜져있습니다.

LOAD_MY_INFO_FAILURE 부분 콘솔 에러입니다.

Error: connect ECONNREFUSED 127.0.0.1:3065

    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {

  errno: -4078,

  code: 'ECONNREFUSED',

  syscall: 'connect',

  address: '127.0.0.1',

  port: 3065,

  config: {

    url: '/user',

    method: 'get',

    headers: {

      Accept: 'application/json, text/plain, */*',

      Cookie: '',

      'User-Agent': 'axios/0.21.1'

    },

    baseURL: 'http://localhost:3065',

    transformRequest: [ [Function: transformRequest] ],

    transformResponse: [ [Function: transformResponse] ],

    timeout: 0,

    withCredentials: true,

    adapter: [Function: httpAdapter],

    xsrfCookieName: 'XSRF-TOKEN',

    xsrfHeaderName: 'X-XSRF-TOKEN',

    maxContentLength: -1,

    maxBodyLength: -1,

    validateStatus: [Function: validateStatus],

    data: undefined

  },

  request: <ref *1> 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,

      prefinished: false,

      errorEmitted: false,

      emitClose: true,

      autoDestroy: true,

      errored: null,

      closed: false

    },

    _events: [Object: null prototype] {

      response: [Function: handleResponse],

      error: [Function: handleRequestError]

    },

    _eventsCount: 2,

    _maxListeners: undefined,

    _options: {

      maxRedirects: 21,

      maxBodyLength: 10485760,

      protocol: 'http:',

      path: '/user',

      method: 'GET',

      headers: [Object],

      agent: undefined,

      agents: [Object],

      auth: undefined,

      hostname: 'localhost',

      port: '3065',

      nativeProtocols: [Object],

      pathname: '/user'

    },

    _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,

      _defaultKeepAlive: true,

      useChunkedEncodingByDefault: false,

      sendDate: false,

      _removedConnection: false,

      _removedContLen: false,

      _removedTE: false,

      _contentLength: 0,

      _hasBody: true,

      _trailer: '',

      finished: true,

      _headerSent: true,

      socket: [Socket],

      _header: 'GET /user HTTP/1.1\r\n' +

        'Accept: application/json, text/plain, */*\r\n' +

        'Cookie: \r\n' +

        'User-Agent: axios/0.21.1\r\n' +

        'Host: localhost:3065\r\n' +

        'Connection: close\r\n' +

        '\r\n',

      _keepAliveTimeout: 0,

      _onPendingData: [Function: noopPendingOutput],

      agent: [Agent],

      socketPath: undefined,

      method: 'GET',

      maxHeaderSize: undefined,

      insecureHTTPParser: undefined,

      path: '/user',

      _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:3065/user',

    [Symbol(kCapture)]: false

  },

  response: undefined,

  isAxiosError: true,

  toJSON: [Function: toJSON]

}

{ type: 'LOAD_MY_INFO_FAILURE', error: 'Error' }

그리고 이건 LOAD_POSTS_FAILURE 부분 콘솔 에러입니다.

Error: connect ECONNREFUSED 127.0.0.1:3065

    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {

  errno: -4078,

  code: 'ECONNREFUSED',

  syscall: 'connect',

  address: '127.0.0.1',

  port: 3065,

  config: {

    url: '/posts?lastId=0',

    method: 'get',

    headers: {

      Accept: 'application/json, text/plain, */*',

      Cookie: '',

      'User-Agent': 'axios/0.21.1'

    },

    baseURL: 'http://localhost:3065',

    transformRequest: [ [Function: transformRequest] ],

    transformResponse: [ [Function: transformResponse] ],

    timeout: 0,

    withCredentials: true,

    adapter: [Function: httpAdapter],

    xsrfCookieName: 'XSRF-TOKEN',

    xsrfHeaderName: 'X-XSRF-TOKEN',

    maxContentLength: -1,

    maxBodyLength: -1,

    validateStatus: [Function: validateStatus],

    data: undefined

  },

  request: <ref *1> 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,

      prefinished: false,

      errorEmitted: false,

      emitClose: true,

      autoDestroy: true,

      errored: null,

      closed: false

    },

    _events: [Object: null prototype] {

      response: [Function: handleResponse],

      error: [Function: handleRequestError]

    },

    _eventsCount: 2,

    _maxListeners: undefined,

    _options: {

      maxRedirects: 21,

      maxBodyLength: 10485760,

      protocol: 'http:',

      path: '/posts?lastId=0',

      method: 'GET',

      headers: [Object],

      agent: undefined,

      agents: [Object],

      auth: undefined,

      hostname: 'localhost',

      port: '3065',

      nativeProtocols: [Object],

      pathname: '/posts',

      search: '?lastId=0'

    },

    _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,

      _defaultKeepAlive: true,

      useChunkedEncodingByDefault: false,

      sendDate: false,

      _removedConnection: false,

      _removedContLen: false,

      _removedTE: false,

      _contentLength: 0,

      _hasBody: true,

      _trailer: '',

      finished: true,

      _headerSent: true,

      socket: [Socket],

      _header: 'GET /posts?lastId=0 HTTP/1.1\r\n' +

        'Accept: application/json, text/plain, */*\r\n' +

        'Cookie: \r\n' +

        'User-Agent: axios/0.21.1\r\n' +

        'Host: localhost:3065\r\n' +

        'Connection: close\r\n' +

        '\r\n',

      _keepAliveTimeout: 0,

      _onPendingData: [Function: noopPendingOutput],

      agent: [Agent],

      socketPath: undefined,

      method: 'GET',

      maxHeaderSize: undefined,

      insecureHTTPParser: undefined,

      path: '/posts?lastId=0',

      _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:3065/posts?lastId=0',

    [Symbol(kCapture)]: false

  },

  response: undefined,

  isAxiosError: true,

  toJSON: [Function: toJSON]

}

{ type: 'LOAD_POSTS_FAILURE', error: 'Error' }

답변 1

0

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

2021. 05. 12. 13:05

백엔드 서버가 꺼져있는 것으로밖에 보이지 않습니다.