title: Node.js / Axios won't connect to localhost
body: <p>I have a cryptocurrency (Nano) node running locally on my computer. It has an RPC API and I've tested that I can successfully make calls to it using curl. E.g.</p>
  
  <p><code>curl -d '{ "action": "account_balance", "account": "xrb_1aaprwcu9fac1tw3wesud5txb1zuiroti5xfr19bwozitjnnmbcbwpr1w95f" }' localhost:7076</code></p>
  
  <p>However I'm trying to do the same thing in a node script and keep getting <code>ECONNREFUSED</code></p>
  
  <p>Here's my node script (the important parts).</p>
  
  <pre><code>const axios = require('axios')
  const config = require('./config')
  
  const rpc = axios.create({
    baseURL: 'localhost:7076', // I've also tried 'http://localhost:7076'
    // I've tried with and without proxy settings, I don't understand proxies very well though
    /*proxy: {
      host: '127.0.0.1',
      port: 7077
    }*/
  })
  
  function createAddress(accountIndex) {
    // Ensure accountIndex is a string
    accountIndex = accountIndex + ''
    // Get a new private key
    return rpc.post('/', {
      action: 'deterministic_key',
      index: accountIndex,
      seed: config.walletSeed
    })
      // Add to the local wallet
      .then(function(result){
        return rpc.post('/', {
          action: 'wallet_add',
          key: result.private,
          wallet: config.walletId
        })
      })
      // Return the account address
      .then(function(result){
        return result.account
      })
      .catch(function(err) {
        console.log('Error', err)
      })
  }
  
  createAddress(52).then(function(address){
    console.log(address)
  })
  </code></pre>
  
  <p>And here's the error.</p>
  
  <pre><code>Error { Error: connect ECONNREFUSED 127.0.0.1:7076
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1170:14)
    errno: 'ECONNREFUSED',
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 7076,
    config:
     { adapter: [Function: httpAdapter],
       transformRequest: { '0': [Function: transformRequest] },
       transformResponse: { '0': [Function: transformResponse] },
       timeout: 0,
       xsrfCookieName: 'XSRF-TOKEN',
       xsrfHeaderName: 'X-XSRF-TOKEN',
       maxContentLength: -1,
       validateStatus: [Function: validateStatus],
       headers:
        { Accept: 'application/json, text/plain, */*',
          'Content-Type': 'application/json;charset=utf-8',
          'User-Agent': 'axios/0.18.0',
          'Content-Length': 117 },
       method: 'post',
       baseURL: 'http://localhost:7076',
       url: 'http://localhost:7076/',
       data: '{"action":"deterministic_key","index":"52","seed":"***"}' },
    request:
     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,
          bufferedRequest: null,
          lastBufferedRequest: null,
          pendingcb: 0,
          prefinished: false,
          errorEmitted: false,
          bufferedRequestCount: 0,
          corkedRequestsFree: [Object] },
       writable: true,
       _events:
        { response: [Function: handleResponse],
          error: [Function: handleRequestError] },
       _eventsCount: 2,
       _maxListeners: undefined,
       _options:
        { protocol: 'http:',
          maxRedirects: 21,
          maxBodyLength: 10485760,
          path: '/',
          method: 'post',
          headers: [Object],
          agent: undefined,
          auth: undefined,
          hostname: 'localhost',
          port: '7076',
          nativeProtocols: [Object],
          pathname: '/' },
       _redirectCount: 0,
       _requestBodyLength: 117,
       _requestBodyBuffers: [ [Object] ],
       _onNativeResponse: [Function],
       _currentRequest:
        ClientRequest {
          _events: [Object],
          _eventsCount: 6,
          _maxListeners: undefined,
          output: [],
          outputEncodings: [],
          outputCallbacks: [],
          outputSize: 0,
          writable: true,
          _last: true,
          upgrading: false,
          chunkedEncoding: false,
          shouldKeepAlive: false,
          useChunkedEncodingByDefault: true,
          sendDate: false,
          _removedConnection: false,
          _removedContLen: false,
          _removedTE: false,
          _contentLength: null,
          _hasBody: true,
          _trailer: '',
          finished: false,
          _headerSent: true,
          socket: [Socket],
          connection: [Socket],
          _header: 'POST / HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: application/json;charset=utf-8\r\nUser-Agent: axios/0.18.0\r\nContent-Length: 117\r\nHost: localhost:7076\r\nConnection: close\r\n\r\n',
          _onPendingData: [Function: noopPendingOutput],
          agent: [Agent],
          socketPath: undefined,
          timeout: undefined,
          method: 'POST',
          path: '/',
          _ended: false,
          res: null,
          aborted: undefined,
          timeoutCb: null,
          upgradeOrConnect: false,
          parser: null,
          maxHeadersCount: null,
          _redirectable: [Circular],
          [Symbol(isCorked)]: false,
          [Symbol(outHeadersKey)]: [Object] },
       _currentUrl: 'http://localhost:7076/' },
    response: undefined }
  </code></pre>
  
  <p>I feel like I've tried countless variations of configuration. What am I not getting?</p>