Server Side Swift with Vapor: Deploying to Heroku | Ray Wenderlich

In this screencast you'll learn how to deploy a Vapor app using PosgreSQL to a production environment using Heroku.

This is a companion discussion topic for the original entry at

Awesome, as usual. Thanks

– Pourpre

Thanks for another great tut :slight_smile:

Thought I’d add the commands used, for reference, I don’t use git/heroku enough to remember :stuck_out_tongue:

git init
git add .
git commit

Add in your message

"Commit Message"

Now setup the project for Heroku

vapor heroku init

Answer the questions

n | n | n | n

Add postgres to the app

heroku addons:create heroku-postgresql:hobby-dev

Update the Config file to use the DatabaseURL

heroku config

Update the Procfile

vi Procfile

Commit your changes

git status
git add .
git commit

Add your message

"Modified procfile"

Now push and wait

git push heroku master

Nice thanks for doing that Alex! That looks like it might be handy for folks who come across this in the future.

1 Like

Do you have a screencast: “Server Side Swift with Vapor: Deploying with Docker”?

Hi. Sorry for asking this question here but I didn’t find the correct place to ask the question. Have any of you tried out Perfect server and what do you think about it? Am trying to Start Swift server side development but I really need to choose the best tool for this. Any input will be highly appreciated.

@tof Not yet but I agree that would be awesome to make!

@gutenberg Haven’t tried out Perfect myself yet. But in case it helps, here’s a quote from @sebastian on the Vapor Slack about his 2c on the various frameworks:

Perfect - Perfect is older and it was first but it was pre-Swift 3 so it does not count I guess. IBM Kitura was started with a big hype and generally puts a lot of attention of server-side Swift which is awesome. But: and yes, there is a big BUT: Vapor is from all 3 the best choice because it is developing faster, more open and with a much stronger community than Perfect or IBM. Additionally, the internals also look much more healthy and powerful and Logan and Tanner are great as project owners.

How I can do the same for MongoDB (mLab) just for Procfile settings?


I followed the tutorial but ran into the following issue with my app.

git push heroku master
remote: ! No such app as salty-crag-95408.
fatal: repository ‘’ not found

I had deleted the ‘salty-crag’ app. Is there any way to change the Heroku app that Vapor deploys to?

@rafael_yami I haven’t looked into MongoDB so am not sure, but maybe someone else can answer.

@agaba This may help:

I worked through the Vapor screencasts, and my app runs fine locally, using a local postgresql database.

However, when I deployed it to heroku, the logs on Heroku are showing this:

2017-01-11T17:36:13.336738+00:00 heroku[web.1]: Process exited with status 132
2017-01-11T17:36:16.486617+00:00 heroku[web.1]: Starting process with command App --env=production --workdir=./ --config:servers.default.port=5614 —-config:postgresql.url=postgres://
2017-01-11T17:36:18.996590+00:00 app[web.1]: fatal error: Error raised at top level: VaporPostgreSQL.Provider.Error.noPostgreSQLConfig: file /home/buildnode/disk2/workspace/oss-swift-3.0-package-linux-ubuntu-14_04/swift/stdlib/public/core/ErrorType.swift, line 184

To me, this means I’ve screwed up the configuration for the app on Heroku somewhere. Anyone have any ideas what I’ve done wrong?

Thanks in advance,

I’m interested in trying this out as I want to start doing server side development in swift. However, I am having an issue even building the project. I get an error when the PostgreSQL target builds as it can’t locate the CPostgreSQLMac module. I’m having trouble finding a framework for this module anywhere. Any advice? Thanks!

hi ray my local postgreqsql workes just fine but after depoloying to heroku i try to save some data i get this error back
“code”: 500,
“error”: true,
“message”: “The operation could not be completed”,
“metadata”: null
any clue why is that?

Thanks for take the time to make this tutorial. I just wanted to comment for those watching that I had an issue with trying to run “vapor heroku init” :- it was giving me an error “Unable to connect to Heroku API, please check internet connectivity and try again.”

After digging for a couple of days, I finally discovered that the default path in the terminal was the problem and that it didn’t point to the version of the heroku command I had intended. This was because a few years back I did a tutorial on Ruby On Rails that changed the path and inserted a different version at the beginning of the path. So finding where the .bash_profile had been changed and reverting that fixed the issue.

I am having a similar issue. Works fine locally, then when deployed it fails.

2017-02-07T22:46:47.133573+00:00 heroku[web.1]: Starting process with command App --env=production --workdir=./ --config:servers.default.port=22759 --config:portgresql.url=postgres://
2017-02-07T22:46:49.241878+00:00 app[web.1]: Production mode enabled, disabling informational logs.
2017-02-07T22:46:49.253625+00:00 app[web.1]: Could not initialize provider Provider: noPostgreSQLConfig
2017-02-07T22:46:49.255083+00:00 app[web.1]: No command supplied, defaulting to serve…
2017-02-07T22:46:49.255254+00:00 app[web.1]: Can not run preparations, droplet has no database
2017-02-07T22:46:49.347605+00:00 heroku[web.1]: State changed from starting to crashed
2017-02-07T22:46:49.337843+00:00 heroku[web.1]: Process exited with status 1
2017-02-07T22:47:16.809194+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/all" request_id=5e84716b-fcc8-4c1a-a1db-e7da56b58cb3 fwd=“” dyno= connect= service= status=503 bytes=

anyone have an idea how to investigate this?

It turned out there must have been a typo of some kind in my Procfile, even though there were no differences that I could see.

I ended up copying the contents from the Procfile in this link, and everything deployed and worked fine.

Postgresql works fine locally. But after deploying it on heroku im getting error

Production mode enabled, disabling informational logs.
2017-02-20T05:48:24.663363+00:00 app[web.1]: fatal error: Error raised at top level: VaporPostgreSQL.Provider.Error.noPostgreSQLConfig: file /home/buildnode/disk2/workspace/oss-swift-3.0-package-linux-ubuntu-14_04/swift/stdlib/public/core/ErrorType.swift, line 184