Postgres revoke database access from user
The right to connect is by default granted to PUBLIC.  You would have to revoke it from PUBLIC (and then grant it individually to other users who need it) to accomplish what you want.

Or use pg_hba.conf to deny the connection.