My slug size is too large, how can I make it smaller?

Issue

You are receiving warnings that your slug is too large, and now your application will not build.

Resolution

Slugs on Heroku consist of your application and all its dependencies, as well as any other dependencies that may be installed by the buildpacks you have specified for your application.

The maximum allowed slug size is 500MB. Slug size varies greatly depending on what language and framework you are using, how many dependencies you have added and other factors specific to your app. Smaller slugs can be transferred to the dyno manager more quickly, allowing for more immediate scaling. You should try to keep your slugs as small and nimble as possible.

You can try and reduce your slug size in a number of ways. The easiest is to add a .slugignore file to your application to tell the slug compiler to ignore any unnecessary files in your application, such as static assets.

To determine what files/folders are taking up space in your slug you can inspect you slug by starting up a one-off dyno like so:

heroku run bash -a <appname>

Once in the dyno you can use the du -heroku * | sort -hr command to show the files and folders in the current directory, ordered by size:

~ $ du -heroku * | sort -hr
22M	bin
20K	cmd
8.0K	logs
8.0K	db
4.0K	go.sum
4.0K	go.mod
4.0K	app.go
4.0K	Procfile

This can be helpful in determining where large files are.

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support
Terms of Service Privacy Cookies © 2019 Salesforce.com