Deploy Failing: Jekyll, Tailwind CSS, PostCSS

Hello!

I’ve been running my Jekyll site on Netlify for months without issue. Recently I’ve been doing work on the site to add in Tailwind CSS. The site deploys locally without issue. However, when I try to deploy (via a Github PR), the deployment is failing. The error message in the log is super cryptic and I can’t make heads or tails of it.

Below is the log message. Does this make sense to anyone?

9:28:54 AM: Build ready to start
9:28:56 AM: build-image version: 2cee85eb7f808bf3b6e87378c5307f9411f0a332
9:28:56 AM: build-image tag: v3.8.0
9:28:56 AM: buildbot version: 30dbdb4695638bcc89067dec803733260bd838a5
9:28:57 AM: Fetching cached dependencies
9:28:57 AM: Starting to download cache of 142.6MB
9:28:58 AM: Finished downloading cache in 1.898790198s
9:28:58 AM: Starting to extract cache
9:29:01 AM: Finished extracting cache in 3.092305346s
9:29:02 AM: Finished fetching cache in 5.031175889s
9:29:02 AM: Starting to prepare the repo for build
9:29:03 AM: Preparing Git Reference pull/9/head
9:29:05 AM: Parsing package.json dependencies
9:29:06 AM: Starting build script
9:29:06 AM: Installing dependencies
9:29:06 AM: Python version set to 2.7
9:29:06 AM: Started restoring cached node version
9:29:09 AM: Finished restoring cached node version
9:29:10 AM: Downloading and installing node v16.5.0...
9:29:10 AM: Downloading https://nodejs.org/dist/v16.5.0/node-v16.5.0-linux-x64.tar.xz...
9:29:10 AM: Computing checksum with sha256sum
9:29:11 AM: Checksums matched!
9:29:14 AM: Now using node v16.5.0 (npm v7.19.1)
9:29:14 AM: Started restoring cached build plugins
9:29:14 AM: Finished restoring cached build plugins
9:29:14 AM: Attempting ruby version 2.7.1, read from environment
9:29:15 AM: Started restoring cached ruby version
9:29:15 AM: Finished restoring cached ruby version
9:29:17 AM: Using ruby version 2.7.1
9:29:17 AM: Using bundler version 2.2.23 from Gemfile.lock
9:29:19 AM: Successfully installed bundler-2.2.23
9:29:19 AM: 1 gem installed
9:29:19 AM: Using PHP version 5.6
9:29:19 AM: Started restoring cached ruby gems
9:29:19 AM: Finished restoring cached ruby gems
9:29:19 AM: Installing gem bundle
9:29:19 AM: [DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set --local path '/opt/build/cache/bundle'`, and stop using this flag
9:29:19 AM: [DEPRECATED] The --binstubs option will be removed in favor of `bundle binstubs --all`
9:29:21 AM: Fetching gem metadata from https://rubygems.org/..........
9:29:21 AM: Resolving dependencies...
9:29:21 AM: Using public_suffix 4.0.6
9:29:21 AM: Using bundler 2.2.23
9:29:21 AM: Using colorator 1.1.0
9:29:21 AM: Using eventmachine 1.2.7
9:29:21 AM: Using http_parser.rb 0.6.0
9:29:21 AM: Using forwardable-extended 2.6.0
9:29:21 AM: Fetching concurrent-ruby 1.1.9
9:29:21 AM: Using rexml 3.2.5
9:29:21 AM: Using liquid 4.0.3
9:29:21 AM: Using mercenary 0.3.6
9:29:21 AM: Fetching ffi 1.15.3
9:29:21 AM: Fetching rb-fsevent 0.11.0
9:29:21 AM: Using rouge 3.26.0
9:29:21 AM: Using safe_yaml 1.0.5
9:29:21 AM: Using jekyll-paginate 1.1.0
9:29:21 AM: Using addressable 2.8.0
9:29:21 AM: Fetching jekyll-postcss 0.4.1
9:29:21 AM: Using kramdown 2.3.1
9:29:21 AM: Using em-websocket 0.5.2
9:29:21 AM: Using pathutil 0.16.2
9:29:21 AM: Using kramdown-parser-gfm 1.1.0
9:29:22 AM: Installing rb-fsevent 0.11.0
9:29:22 AM: Installing jekyll-postcss 0.4.1
9:29:22 AM: Installing concurrent-ruby 1.1.9
9:29:22 AM: Installing ffi 1.15.3 with native extensions
9:29:22 AM: Using i18n 0.9.5
9:29:31 AM: Using rb-inotify 0.10.1
9:29:31 AM: Using sass-listen 4.0.0
9:29:31 AM: Using listen 3.5.1
9:29:31 AM: Using sass 3.7.4
9:29:31 AM: Using jekyll-watch 2.2.1
9:29:31 AM: Using jekyll-sass-converter 1.5.2
9:29:31 AM: Using jekyll 3.9.1
9:29:31 AM: Using jekyll-feed 0.15.1
9:29:31 AM: Bundle complete! 5 Gemfile dependencies, 30 gems now installed.
9:29:31 AM: Bundled gems are installed into `/opt/build/cache/bundle`
9:29:31 AM: Gem bundle installed
9:29:31 AM: Started restoring cached node modules
9:29:31 AM: Finished restoring cached node modules
9:29:32 AM: Installing NPM modules using NPM version 7.19.1
9:29:36 AM: added 138 packages, and audited 139 packages in 4s
9:29:36 AM: 21 packages are looking for funding
9:29:36 AM:   run `npm fund` for details
9:29:36 AM: found 0 vulnerabilities
9:29:36 AM: NPM modules installed
9:29:36 AM: Started restoring cached go cache
9:29:36 AM: Finished restoring cached go cache
9:29:36 AM: go version go1.14.4 linux/amd64
9:29:36 AM: go version go1.14.4 linux/amd64
9:29:36 AM: Installing missing commands
9:29:36 AM: Verify run directory
9:29:37 AM: ​
9:29:37 AM: ────────────────────────────────────────────────────────────────
9:29:37 AM:   Netlify Build                                                 
9:29:37 AM: ────────────────────────────────────────────────────────────────
9:29:37 AM: ​
9:29:37 AM: ❯ Version
9:29:37 AM:   @netlify/build 15.11.4
9:29:37 AM: ​
9:29:37 AM: ❯ Flags
9:29:37 AM:   deployId: 60f03816343ee6000800e638
9:29:37 AM: ​
9:29:37 AM: ❯ Current directory
9:29:37 AM:   /opt/build/repo
9:29:37 AM: ​
9:29:37 AM: ❯ Config file
9:29:37 AM:   No config file was defined: using default values.
9:29:37 AM: ​
9:29:37 AM: ❯ Context
9:29:37 AM:   deploy-preview
9:29:37 AM: ​
9:29:37 AM: ────────────────────────────────────────────────────────────────
9:29:37 AM:   1. Build command from Netlify app                             
9:29:37 AM: ────────────────────────────────────────────────────────────────
9:29:37 AM: ​
9:29:37 AM: $ jekyll build --trace
9:29:38 AM: Configuration file: /opt/build/repo/_config.yml
9:29:48 AM: /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:70:in `rescue in start_dev_server': Could not connect to the PostCSS server (RuntimeError)	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:61:in `start_dev_server'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:13:in `initialize'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `new'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `block in initialize'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `fetch'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `initialize'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/site.rb:295:in `new'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/site.rb:295:in `block in instantiate_subclasses'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/site.rb:294:in `map'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/site.rb:294:in `instantiate_subclasses'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/site.rb:116:in `setup'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/site.rb:32:in `initialize'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/commands/build.rb:30:in `new'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/commands/build.rb:30:in `process'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'	from /opt/build/cache/bundle/ruby/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'	from /opt/build/cache/bundle/ruby/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'	from /opt/build/cache/bundle/ruby/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'	from /opt/build/cache/bundle/ruby/2.7.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'	from /opt/build/cache/bundle/ruby/2.7.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/exe/jekyll:15:in `<top (required)>'	from /opt/build/cache/binstubs/jekyll:29:in `load'	from /opt/build/cache/binstubs/jekyll:29:in `<main>'/opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:62:in `initialize': Cannot assign requested address - connect(2) for "localhost" port 8124 (Errno::EADDRNOTAVAIL)	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:62:in `open'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:62:in `start_dev_server'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:13:in `initialize'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `new'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `block in initialize'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `fetch'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `initialize'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/site.rb:295:in `new'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/site.rb:295:in `block in instantiate_subclasses'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/site.rb:294:in `map'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/site.rb:294:in `instantiate_subclasses'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/site.rb:116:in `setup'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/site.rb:32:in `initialize'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/commands/build.rb:30:in `new'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/commands/build.rb:30:in `process'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'	from /opt/build/cache/bundle/ruby/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'	from /opt/build/cache/bundle/ruby/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'	from /opt/build/cache/bundle/ruby/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'	from /opt/build/cache/bundle/ruby/2.7.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'	from /opt/build/cache/bundle/ruby/2.7.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'	from /opt/build/cache/bundle/ruby/2.7.0/gems/jekyll-3.9.1/exe/jekyll:15:in `<top (required)>'	from /opt/build/cache/binstubs/jekyll:29:in `load'	from /opt/build/cache/binstubs/jekyll:29:in `<main>'​
9:29:48 AM: ────────────────────────────────────────────────────────────────
9:29:48 AM:   "build.command" failed                                        
9:29:48 AM: ────────────────────────────────────────────────────────────────
9:29:48 AM: ​
9:29:48 AM:   Error message
9:29:48 AM:   Command failed with exit code 1: jekyll build --trace
9:29:48 AM: ​
9:29:48 AM:   Error location
9:29:48 AM:   In Build command from Netlify app:
9:29:48 AM:   jekyll build --trace
9:29:48 AM: ​
9:29:48 AM:   Resolved config
9:29:48 AM:   build:
9:29:48 AM:     command: jekyll build --trace
9:29:48 AM:     commandOrigin: ui
9:29:48 AM:     environment:
9:29:48 AM:       - NODE_ENV
9:29:48 AM:       - NODE_VERSION
9:29:48 AM:       - REVIEW_ID
9:29:48 AM:     publish: /opt/build/repo/_site
9:29:48 AM:     publishOrigin: ui
9:29:48 AM: Caching artifacts
9:29:48 AM: Started saving ruby gems
9:29:48 AM: Finished saving ruby gems
9:29:48 AM: Started saving node modules
9:29:48 AM: Finished saving node modules
9:29:48 AM: Started saving build plugins
9:29:48 AM: Finished saving build plugins
9:29:48 AM: Started saving pip cache
9:29:48 AM: Finished saving pip cache
9:29:48 AM: Started saving emacs cask dependencies
9:29:49 AM: Finished saving emacs cask dependencies
9:29:49 AM: Started saving maven dependencies
9:29:49 AM: Finished saving maven dependencies
9:29:49 AM: Started saving boot dependencies
9:29:49 AM: Finished saving boot dependencies
9:29:49 AM: Started saving rust rustup cache
9:29:49 AM: Finished saving rust rustup cache
9:29:49 AM: Started saving go dependencies
9:29:49 AM: Finished saving go dependencies
9:29:52 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:29:52 AM: Creating deploy upload records
9:29:52 AM: Failing build: Failed to build site
9:29:52 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
9:29:52 AM: Finished processing build request in 55.896282278s

URL for anyone with better access: Netlify App

Thanks in advance!

If you’re interested, you can see the code/config here: https://github.com/rwgrier/rwgrier.github.io/tree/tailwindcss

I gave up on this and just generated the css file I needed and deployed that without issue.

I had the same error. The solution turned out to be: run the build with command:
JEKYLL_ENV=production jekyll build

1 Like

Can confirm this worked for me as well. Have had this problems for a long time and this fixed it.

1 Like

I also confirm @emcoding’s solution works and the build was failing with simple jekyll build command

1 Like

UPDATE:

It does work with bundle exec jekyll build, and that’s what Netlify’s default command is, NOT jekyll build.

And I believe, my JEKYLL_ENV=production jekyll build command was automatically converted to bundle exec jekyll build under the hood. That’s what I see in my build settings, even though I saved the other one.

The fact that the guide doesn’t show the actual command and only mentions that the default parameters gathered by Netlify are appropriate, doesn’t help.

I wrote a guide for a simpler way to use Jekyll with Tailwind.

Jekyll + Tailwind2 + Netlify. Here’s the new solution for your Ruby… | by Maud de Vries | Medium (friends-link) or to support me: Jekyll + Tailwind2 + Netlify. Here’s the new solution for your Ruby… | by Maud de Vries | Medium

1 Like

@emcoding Thanks for sharing!

1 Like

Previously I said that it works with bundle exec jekyll build, but that no longer seems to be the case. My current working build command is this:

JEKYLL_ENV=production bundle exec jekyll build

I recently wrote about how to make Tailwind work with Jekyll: mzrnsh › Starting a blank Jekyll site with Tailwind CSS in 2022. It addresses the above deployment issue as well.

Hope this helps someone.

1 Like

Thanks for reporting back, it’ll definitely help some people!

2 Likes