Jan 13, 2021 2 mins

ERROR: permission denied for tablespace pg_default

Learn Python Learn Python

The following error occurred when I tried to create a new Postgres Database. I'm using DBeaver to access my Postgres server.

Permission denied for tablespace


ERROR: permission denied for tablespace pg_default

Why is This Error?

The ERROR: permission denied for tablespace pg_default” error in PostgreSQL indicates that the user attempting to perform an operation (such as creating a table or index) does not have the necessary permissions to access or use the specified tablespace, typically pg_default. A tablespace in PostgreSQL is a location on disk where the database stores its data.

Here’s a breakdown of the key components of the error

ERROR: Indicates that there is a problem or issue.

permission denied for tablespace pg_default: Specifies that the user lacks the necessary permissions to access the specified tablespace (pg_default in this case).

To address this error, consider the following steps

Check User Permissions: Verify the permissions of the user attempting the operation. Ensure that the user has the necessary privileges to create tables or perform other operations in the specified tablespace.

For example, you can grant the required privileges using the following SQL command:

GRANT CREATE ON TABLESPACE pg_default TO <username>;

Review Table and Database Permissions: Confirm that the user also has the required permissions on the specific table or database where the operation is being performed.

For example, to grant permissions on a specific table, you can use:

GRANT <permissions> ON TABLE <table_name> TO <username>;

Check Default Tablespace: Ensure that the default tablespace for the user is set appropriately. You can set the default tablespace for a user during user creation or modify it later.

For example, to set the default tablespace for a user:

ALTER USER <username> SET default_tablespace = <tablespace_name>;

Examine Disk Space: Verify that there is sufficient disk space available in the specified tablespace. If the tablespace is running out of space, PostgreSQL may restrict further operations.

Review PostgreSQL Logs: Examine the PostgreSQL error logs for more details on the error. Logs often provide additional information about the context and the nature of the permission issue.

By checking user permissions, reviewing table and database permissions, ensuring an adequate disk space, and examining PostgreSQL logs, you can troubleshoot and resolve the “ERROR: permission denied for tablespace pg_default” issue in PostgreSQL.


  • Avatar

    Danielle Carline

    Posted on

    There are two possible solutions to avoid this error.

    Grant User/User groups/Roles

    Grant users to create databases with pg_default table space. Here is an example.


    You can find more details on grating users to table space here.

    Use default table_space

    You can use the default table_space when you create a new database. Here is a GPU example. Note that the default table space is not recommended at the production level.

    Permission denied for tablespace

Write a comment

You can use the Markdown syntax to format your comment.

  • Tags:
  • python
  • Share: