0

This seems like it should be very simple, however I can't find any solutions.

I had a server, lets call it "server1", and it was connected to a database, lets call it "database1". Both the server and database are hosted on Heroku.

I have created a new server, lets call it "server2", and it is also hosted on Heroku.

I want to connect server2 to database1. How do I do this?

Background info:

  1. Both servers are using node.js
  2. The database is postgreSQL.

server1 -> database1

server2 -> null

How can I make it to where:

server2 -> database1


I don't care if server1 stays connected or doesn't, I just want to connect server2 to database1.

Thank you!

ezg
  • 715
  • 2
  • 7
  • 20
  • Does this answer your question? [Share database between 2 apps in Heroku](https://stackoverflow.com/questions/5981508/share-database-between-2-apps-in-heroku) – RangerRanger Apr 10 '20 at 14:10

1 Answers1

0

Well, I just found the answer, enter this into the server's console:

heroku addons:attach <database_name> -a <server_name>

Or in my case:

heroku addons:attach <database1> -a <server2>

Also, server1 will no longer be attached to database1.

ezg
  • 715
  • 2
  • 7
  • 20