pg_restore ERROR: "Relation does not exist" and creating new database
When --create and -d are used together, the argument to -d is not the name of the database to create, it's the name of an existing database to connect to run the CREATE DATABASE statement, because it's impossible to create a database if you're not already connect to another database.

This is documented as:


  When this option is used, the database named with -d is used only to
  issue the initial DROP DATABASE and CREATE DATABASE commands. All data
  is restored into the database name that appears in the archive.


This is why pg_restore errors out with database temp does not exist

You should add a createdb step in your restore procedure since you want to create a specific database name anyway, not one that comes from the backup.

For the second problem, it's a completely different question, hard to guess why it happens without complete error messages.

Also note that -p is not followed by a password but by a port number.