<pre><code>FATAL: no PostgreSQL user name specified in startup packet
</code></pre>

<p>Logs from my postgreSQL instance in my kubernetes cluster when trying to connect to it by doing the following:</p>

<pre><code>const { POSTGRES_DATABASE, POSTGRES_USERNAME, POSTGRES_PASSWORD } = require('../config/config');

const Sequelize = require('sequelize');
    const conn = new Sequelize(POSTGRES_DATABASE, {
        username: POSTGRES_USERNAME,
        password: POSTGRES_PASSWORD
    });
</code></pre>

<p>config/config.js</p>

<pre><code>    const config = {
        POSTGRES_DATABASE: 'postgres://postgres/postgresdb',
        POSTGRES_USERNAME: 'postgresadmin',
        POSTGRES_PASSWORD: 'admin123',
        SERVER_PORT: '5000'
    }

module.exports = config;
</code></pre>

<p>I am using SequelizeJS in nodeJS.
<a href="http://docs.sequelizejs.com/" rel="nofollow noreferrer">http://docs.sequelizejs.com/</a></p>

<p>It seems like the requests are connecting alright due to seeing the attempts in the postgreSQL logs. However something goes wrong and I wonder if it's wrong with permissions in postgres or the node service.</p>

<p>Appreciate some help or ideas</p>

Joelgullander
<p>According to the Sequelize documentation that you linked, the args to creating a new connection are db, username, password. Your code did db, and then an object with username and password keys. This object is not correct and caused it to not find the username or password. Try this instead:</p>

<pre><code>const { POSTGRES_DATABASE, POSTGRES_USERNAME, POSTGRES_PASSWORD } = require('../config/config');

const Sequelize = require('sequelize');
const conn = new Sequelize(POSTGRES_DATABASE, POSTGRES_USERNAME, POSTGRES_PASSWORD);
</code></pre>

<p>Sequelize <em>does</em> allow for an optional options object as the last argument, but the username and password are not expected to be in there. </p>

<p>This page of the documentation feels confusing to me.</p>

<p><a href="http://docs.sequelizejs.com/manual/installation/usage.html" rel="nofollow noreferrer">http://docs.sequelizejs.com/manual/installation/usage.html</a></p>

<p>I believe what it says is that you either need to define everything in the object, or do the database, username, and password as separate arguments, but I don’t see it supporting database in the arguments and username / password in the object. </p>

<p>It seems like this should work as well:</p>

<pre><code>const conn = new Sequelize({
  database: POSTGRES_DATABASE,
  username: POSTGRES_USERNAME,
  password: POSTGRES_PASSWORD
});
</code></pre>
