jekyll-postcss icon indicating copy to clipboard operation
jekyll-postcss copied to clipboard

Could not connect to the PostCSS server (RuntimeError)

Open olakara opened this issue 3 years ago • 12 comments

I am running jekyll with jekyll-process through docker compose:

version: '3.3'

services:
  jekyll:
    image: jekyll/jekyll:latest
    #    command: jekyll serve --watch --force_polling --verbose --trace
    command: jekyll serve --livereload --drafts --future --port 4000 --livereload_port 35729
    ports:
      - 4000:4000
    volumes:
      - .:/srv/jekyll
    environment:
      - JEKYLL_ROOTLESS=true

I keep getting error:

jekyll_1  | Configuration file: /srv/jekyll/_config.yml
jekyll_1  | jekyll 3.8.7 | Error:  Could not connect to the PostCSS server
jekyll_1  | /usr/gem/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)
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:61:in `start_dev_server'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:13:in `initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `new'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `block in initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `fetch'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:295:in `new'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:295:in `block in instantiate_subclasses'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:294:in `map'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:294:in `instantiate_subclasses'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:116:in `setup'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:32:in `initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/build.rb:30:in `new'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/build.rb:30:in `process'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `block in start'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `each'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `start'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/exe/jekyll:15:in `<top (required)>'
jekyll_1  |     from /usr/local/bundle/bin/jekyll:29:in `load'
jekyll_1  |     from /usr/local/bundle/bin/jekyll:29:in `<main>'
jekyll_1  | /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:62:in `initialize': Address not available - connect(2) for "localhost" port 8124 (Errno::EADDRNOTAVAIL)
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:62:in `open'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:62:in `start_dev_server'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll-postcss/socket.rb:13:in `initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `new'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `block in initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `fetch'
jekyll_1  |     from /usr/gem/gems/jekyll-postcss-0.4.1/lib/jekyll/converters/postcss.rb:15:in `initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:295:in `new'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:295:in `block in instantiate_subclasses'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:294:in `map'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:294:in `instantiate_subclasses'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:116:in `setup'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/site.rb:32:in `initialize'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/build.rb:30:in `new'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/build.rb:30:in `process'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `block in start'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `each'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `start'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
jekyll_1  |     from /usr/gem/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
jekyll_1  |     from /usr/gem/gems/jekyll-3.8.7/exe/jekyll:15:in `<top (required)>'
jekyll_1  |     from /usr/local/bundle/bin/jekyll:29:in `load'
jekyll_1  |     from /usr/local/bundle/bin/jekyll:29:in `<main>'

Any idea how to resolve this?

olakara avatar Jun 03 '21 08:06 olakara

You need node js to use post css. I assume that the Jekyll image does not include it.

mhanberg avatar Jun 03 '21 13:06 mhanberg

@mhanberg thanks for your input.. I did following: docker-compose run jekyll /bin/bash and ran node --version Looks like I have nodejs ..

image

olakara avatar Jun 05 '21 06:06 olakara

@olakara Please remove the env var JEKYLL_ROOTLESS and try again.

Atem18 avatar Jul 12 '21 11:07 Atem18

I am seeing this same error when I attempt to deploy via Netlify. I feel like I'm doing something silly with my config.

Netlify Support Post: https://answers.netlify.com/t/deploy-failing-jekyll-tailwind-css/41017

Github Branch with all of my attempts: https://github.com/rwgrier/rwgrier.github.io/tree/tailwindcss

rwgrier avatar Jul 15 '21 14:07 rwgrier

@rwgrier there is a 404 on your link

Atem18 avatar Jul 16 '21 17:07 Atem18

@Atem18 Sorry, I got kinda frustrated and gave up on it. I moved to a generated version of the Tailwind CSS file.

rwgrier avatar Jul 16 '21 20:07 rwgrier

@rwgrier No problem, if you ever want to see a working example, please see my website here : https://github.com/Atem18/atemlire

Atem18 avatar Jul 20 '21 11:07 Atem18

@Atem18 I cloned your repo https://github.com/Atem18/atemlire.git and tried to run .. and ended up with the same error: image

all I did was run this command: docker run --name=atemlire-dev --volume="C:/Users/Lenovo/source/atemlire/app:/srv/jekyll" -p 4000:4000 -it jekyll/jekyll:4.2.0 jekyll serve --drafts --incremental

olakara avatar Jul 24 '21 05:07 olakara

@olakara If you go upper, you will see the real error. It's probably because the node_modules are missing.

I pushed an update to my repo and the trick is to build your own image and override the ENTRYPOINT because for whatever reason, there is nodejs in the official Jekyll docker image but while it does install the Ruby Gems, it does not install the Node packages.

Do note that I did many tests with Docker Compose and there is always that error and I have no clue why it's not working with Docker Compose but it's working with Docker.

Atem18 avatar Jul 24 '21 17:07 Atem18

I am observing the same behavior with a very similar docker-compose.yml file for my Jekyll project. I tried building a custom image based on Ruby:3.0.2 with nodejs and npm installed explicitly, and with port 8124 exposed (not sure whether this is needed) and when attempting to run a container based on that image with docker-compose, am observing the same behavior as well.

tyHdev avatar Aug 01 '21 04:08 tyHdev

I get the same error running with the following docker-compose.yml file:

services:
  jekyll:
    image: jekyll/jekyll:latest
    command: jekyll s -l
    ports:
      - 4000:4000
    volumes:
      - .:/srv/jekyll

guschiavon avatar Nov 01 '21 12:11 guschiavon

@olakara @guschiavon
I could fix it by specifing the jekyll environment variable:

environment:
      - JEKYLL_ENV=development jekyll build

codejanovic avatar Jul 20 '22 19:07 codejanovic