Skip to content
A simple Vapor app that works with a PostgreSQL database, deployable on Heroku.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A simple Vapor app that works with a PostgreSQL database, deployable on Heroku.


Try brew install vapor/tap/vapor heroku-cli postgres

Create from scratch

vapor new postdb --template=twostraws/vapor-clean
cd postdb
vapor xcode -y

# make Procfile for Heroku
echo "web: Run --env production --hostname --port \$PORT
local: vapor run" > Procfile

Follow the HackingWithSwift article, substituting a PostgreSQL database for the SQLite one they use. Used the Medium article to help with that. Then used prior knowledge from with other searches online to troubleshoot deployment to Heroku.


Before running locally, you must have a Postgres server running with a database ready to use. In the project it is named vapor_pg_test. Use these steps:

# set up database and start postgres server
createdb vapor_pg_test
postgres -D /usr/local/var/postgres/ &


# start app server
pushd postdb
vapor run & # or run the `Run` scheme in Xcode.

# open browser to app
open http://localhost:8080

Locally with Heroku

pushd postdb
heroku local local &
open http://localhost:8080


# provision heroku app with working vapor buildpack
heroku create --buildpack # vapor/vapor is supposed to be the stable release but currently doesn't work
heroku stack:set heroku-16 -a <app-name> # the buildpack doesn't work on the current default stack heroku-18, so we must downgrade

# provision a heroku postgresql addon
heroku addons:create heroku-postgresql:hobby-dev

# deploy and browse to app
git subtree push --prefix postdb heroku master # heroku wants everything to be in the root directory, but I don't wanna
heroku open


Preserved in docs/.


Issues and pull requests are welcome!

If this project helped you, please consider leaving a tip 🤗

Do you need help with a project? I'm currently available for hire or contract..

You can’t perform that action at this time.