Skip to content

Error: connect ECONNREFUSED ::1:8080 when connecting to the OnePassword Connect server  #112

Open
@skoblenick

Description

@skoblenick

Your environment

SDK Version: 1.4.1

Connect Server Version: 1.7.2

OS: MacOS 11.7.9 (Big Sur - Intel) with Rancher Desktop and Docker

Node Version: v18.18.2

What happened?

Using the serverURL of http://localhost:8080 attempts to resolve via IPv6 and fails to resolve the host causing the connection to the op-connect-api container to fail when running in local development. Using Rancher Desktop & Docker.

What did you expect to happen?

No error connecting to the op-connect-api Docker Container and a list of vault/secrets to be returned.

Steps to reproduce

  1. Create a Secrets Automation save the .json and token.

  2. Setup OnePassword Connect server per https://developer.1password.com/docs/connect/get-started/#step-2-deploy-1password-connect-server with Rancher Desktop and Docker.

    • Verify connection returns values with:
         curl \
           -H "Accept: application/json" \
           -H "Authorization: Bearer $OP_API_TOKEN" \
           http://localhost:8080/v1/vaults
    
  3. Create a basic test.ts file with:

    import { OnePasswordConnect, Vault } from '@1password/connect';
    
    export async function getSecrets(): Promise<Vault[]> {
      try {
        const op = OnePasswordConnect({
          serverURL: 'http://localhost:8080',
          token: 'my-token',
          keepAlive: true,
        });
    
        return await op.listVaults();
      } catch (err) {
        return Promise.reject(err);
      }
    }
    
    async function main() {
      console.log('vaults:', await getSecrets());
    }
    
    main();
  4. run the file with ts-node ./test.ts, which results in:

        cause: Error: connect ECONNREFUSED ::1:8080
        at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
          errno: -61,
          code: 'ECONNREFUSED',
          syscall: 'connect',
          address: '::1',
          port: 8080
        }
    
  5. Changing serverURL to http://127.0.0.1:8080 and rerunning the script then works as expected; returning a list of vaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions