Error during migration run: no PostgreSQL user name specified in startup packet

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ned1
    New Member
    • Feb 2021
    • 1

    Error during migration run: no PostgreSQL user name specified in startup packet

    yarn migrate:run && yarn start
    yarn typeorm migration:run --config ./lib/src/ormconfig
    /usr/src/app/node_modules/.bin/typeorm migration:run --config ./lib/src/ormconfig
    Error during migration run:
    { error: no PostgreSQL user name specified in startup packet
    at Connection.pars eE (/usr/src/app/node_modules/pg/lib/connection.js:6 06:11)
    at Connection.pars eMessage (/usr/src/app/node_modules/pg/lib/connection.js:4 03:19)
    at Socket.<anonymo us> (/usr/src/app/node_modules/pg/lib/connection.js:1 23:22)
    at Socket.emit (events.js:193: 13)
    at addChunk (_stream_readab le.js:295:12)
    at readableAddChun k (_stream_readab le.js:276:11)
    at Socket.Readable .push (_stream_readab le.js:231:10)
    at TCP.onStreamRea d (internal/stream_base_com mons.js:154:17)
    name: 'error',
    length: 121,
    severity: 'FATAL',
    code: '28000',
    detail: undefined,
    hint: undefined,
    position: undefined,
    internalPositio n: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'postmaster.c',
    line: '2217',
    routine: 'ProcessStartup Packet' }
    error Command failed with exit code 1.
  • Niheel
    Recognized Expert Moderator Top Contributor
    • Jul 2005
    • 2432

    #2
    Double check your ormconfig file at /lib/src/ormfconfig

    It might look like this.
    Code:
    import { ConnectionOptions } from 'typeorm';
     
    const config: ConnectionOptions = {
      type: 'postgres',
      host: process.env.POSTGRES_HOST,
      port: Number(process.env.POSTGRES_PORT),
      username: process.env.POSTGRES_USER,
      password: process.env.POSTGRES_PASSWORD,
      database: process.env.POSTGRES_DB,
      entities: [
        __dirname + '/../**/*.entity{.ts,.js}',
      ],
      cli: {
        migrationsDir: 'src/migrations',
      }
    };
     
    export = config;
    You might need to change your env variables. Or you can try manually inserting them in that file after the ":".

    more information here:
    ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms. -...
    niheel @ bytes

    Comment

    Working...