Where PostgreSQL stores your username
Your PostgreSQL username is the account name you use to connect to the database server. It is not your computer login or your web hosting username — it is specific to PostgreSQL itself. The username lives in PostgreSQL's own user table, not in your operating system or your hosting control panel.
If you set up PostgreSQL yourself on your own machine, you created the username during installation. If your hosting provider set it up for you, they sent it to you in a welcome email or you can find it in your hosting control panel. The method to retrieve it depends on which situation you are in.
Key Takeaways
- Your PostgreSQL username is stored inside the database server itself, not in your operating system or hosting control panel.
- If you have command-line access to the server, you can list all usernames by connecting as the default postgres user and running \du.
- Hosting providers usually show your PostgreSQL username in the database management section of your control panel, often labeled cPanel, Plesk, or a custom dashboard.
- The default PostgreSQL superuser is always named postgres, and this account exists on every PostgreSQL installation.
- If you cannot find your username anywhere, you may need to reset the postgres password or contact your hosting provider's support team.
Check your hosting control panel first
If PostgreSQL is hosted by a web hosting company, they provide a control panel where you manage databases. Log in to your hosting account and look for a section called Databases, PostgreSQL, or Database Management. The exact name varies by provider — cPanel uses "PostgreSQL Databases", Plesk uses "Databases", and some providers have custom dashboards.
Once you find the database section, you will see a list of databases you own. Next to each database, the username that owns it is usually shown in a column labeled "User", "Owner", or "Username". Write down the username exactly as it appears, including any numbers or underscores.
If your hosting provider does not show usernames in the control panel, check your welcome email from when you created the database. Most providers send a confirmation email with the database name, username, and password all together.
Use the command line if you have server access
If you have SSH access to the server where PostgreSQL runs, you can connect directly and list all usernames. Open a terminal and connect to your server, then switch to the postgres user by typing sudo -u postgres psql. This command opens the PostgreSQL prompt using the default superuser account.
Once you are at the PostgreSQL prompt (you will see postgres=#), type \du and press Enter. This command displays a table of all users on the server, their roles, and their permissions. Your username will appear in the leftmost column. Type \q to exit the prompt when you are done.
If you do not have the postgres password, you may still be able to connect if you are logged in as the root user on the server itself. PostgreSQL allows the root user to connect without a password in many default configurations.
Check your database connection configuration files
PostgreSQL clients often store connection details in configuration files on your computer. On Linux and Mac, look for a file named .pgpass in your home directory. On Windows, look for pgpass.conf in %APPDATA%\postgresql. These files store saved connection credentials in the format hostname:port:database:username:password.
You can also check any process that connects to PostgreSQL. If you use a tool like pgAdmin, DBeaver, or a web process, the connection settings usually show the username. In pgAdmin, expand the Servers section on the left, right-click the server you use, and select Properties. The username appears under the Connection tab.
The default postgres superuser account
Every PostgreSQL installation includes a default superuser named postgres. This account always exists and has full permissions on the entire server. If you cannot find any other username, postgres is the account to try first.
On a fresh installation, the postgres account has no password set, or the password is blank. On hosted systems, the provider usually sets a password during setup and sends it to you. If you have the password for the postgres account, you can use it to connect and then create or manage other usernames.
What to do if you still cannot find it
If you have checked your control panel, your email, and your configuration files and still cannot locate the username, contact your hosting provider's support team. Tell them the domain name or account number associated with your PostgreSQL database, and they can look up the username in their records. Most providers respond within a few hours.
If you set up PostgreSQL on your own server and forgot the username, you have two options. If you remember the password, you can try connecting with common default names like postgres, admin, or root. If you do not remember the password either, you will need to reset the postgres account password using the server's operating system access, which requires root or administrator privileges.
Frequently Asked Questions
Is my PostgreSQL username the same as my database name?
No. The database name and username are separate. A single username can own multiple databases, and a single database can be accessed by multiple users with different permissions. You need both pieces of information to connect.
Can I change my PostgreSQL username?
Yes, but it requires superuser access. If you have access to the postgres account or another superuser, you can rename a user with the ALTER USER oldname RENAME TO newname command. Most hosting providers do not allow you to change usernames through the control panel, so you would need to contact support.
What if I see multiple usernames in the \du output?
PostgreSQL servers often have several system users in addition to your own. Look for the username that matches your database name or your hosting account name. System users usually have names like postgres, pg_database_owner, or pg_monitor.
Does my PostgreSQL username have to match my database name?
No. You can name them anything you want, and they do not have to match. However, many hosting providers create them with the same name to make them easier to remember. Check your control panel to see what your provider chose.
What should I do if my hosting provider will not tell me my username?
Ask them to send you the database connection details again, or ask them to reset the password for the account. Most providers will do this without charge. If they refuse, that is a sign of poor support and you may want to consider switching providers.