# Extremely slow dev server

**URL:** <https://discourse.gohugo.io/t/extremely-slow-dev-server/53344>\
**Category:** support\
**Created:** [January 31, 2025, 11:27pm UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344 "2025-01-31T23:27:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlanBreck](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/alanbreck/32/11694_2.png) [@AlanBreck](https://discourse.gohugo.io/u/AlanBreck)\
**Post date:** [January 31, 2025, 11:27pm UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/1 "2025-01-31T23:27:26Z")

</div>

I’m in the process of upgrading from `0.119.x` to `0.142.0` (finally). When running `hugo` I get build times similar to what I’ve been getting on `0.119`, however when running `hugo server`, it’s taking around 16mins to build before the live server starts.

I unfortunately can’t share the repo as it’s private. I would attempt to reproduce in a demo, but I don’t really know where to start.

Are there areas to which I should pay particular attention that could be the culprit in this massive build time difference?

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [February 1, 2025, 6:02am UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/2 "2025-02-01T06:02:36Z")

</div>

Run the [server](https://gohugo.io/commands/hugo_server/) with `--templateMetrics` and `--templateMetricsHints` and identify the layout files that slow things down. In my experience it’s image processing (do not delete/ignore `resources` folder after one initial slow run) and pager for list pages (use higher limits for the displayed items per page).

---

<div class="post-metadata">

**Author:** ![zhandosweb](https://avatars.discourse-cdn.com/v4/letter/z/b19c9b/32.png) [@zhandosweb](https://discourse.gohugo.io/u/zhandosweb)\
**Post date:** [February 1, 2025, 9:30pm UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/3 "2025-02-01T21:30:42Z")

</div>

Sorry for the off-topic question, but how many pages does your site have? 16 minutes seems too long to me, especially when Hugo is claimed to be the fastest SSG on the market.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [February 1, 2025, 10:30pm UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/4 "2025-02-01T22:30:31Z")

</div>

> [@AlanBreck](#):
>
> Are there areas to which I should pay particular attention that could be the culprit in this massive build time difference?

You need to provide much better information about your site. There’s no way anyone can guess bassed in the few sentecnes you’ve given.

---

<div class="post-metadata">

**Author:** ![AlanBreck](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/alanbreck/32/11694_2.png) [@AlanBreck](https://discourse.gohugo.io/u/AlanBreck)\
**Post date:** [February 2, 2025, 3:30am UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/5 "2025-02-02T03:30:18Z")

</div>

Thanks, @davidsneighbour! I don’t _think_ it’s a general layout performance issue since running a build without using the dev server (i.e. `hugo`) is completing in a reasonable, expected amount of time. It’s _only_ when running the dev server that I get the unusually long build times. I’m also not getting the same disparate build times in 0.119.x.

> You need to provide much better information about your site.

I’d be glad to, but I’m not really certain where to start. Potentially relevant parts of the puzzle that come to mind:

- Stylesheets use Sass and `toCSS` (configured for Dart Sass) for transformation.
- I’m using Tailwind 3.x via `postCSS`
- My primary stylesheet loading looks like the below:

```go
{{- $css := resources.Get "scss/main.scss" | toCSS (merge $toCSSOptions (dict "targetPath" "static-assets/css/main.css")) | postCSS $postCSSOptions -}}
{{- if not hugo.IsDevelopment -}}
    {{ $css = $css | minify | fingerprint }}
{{- end -}}
{{ with $css }}
  {{ if not hugo.IsDevelopment }}
    <link href="{{ .RelPermalink }}" rel="stylesheet" data-integrity="{{ .Data.Integrity }}" />
  {{ else }}
    <link href="{{ .RelPermalink }}" rel="stylesheet" />
  {{ end }}
{{ end }}

{{ with .CurrentSection.Resources.GetMatch "styles.section.{scss,css}" }}
    {{- $sectionCSS := . | toCSS $toCSSOptions | postCSS $postCSSOptions -}}
    {{- if not hugo.IsDevelopment -}}
        {{ $sectionCSS = $sectionCSS | minify | fingerprint }}
    {{- end -}}
    {{ with $sectionCSS }}
      {{ if not hugo.IsDevelopment }}
        <link href="{{ .RelPermalink }}" rel="stylesheet" data-integrity="{{ .Data.Integrity }}" />
      {{ else }}
        <link href="{{ .RelPermalink }}" rel="stylesheet" />
      {{ end }}
    {{ end }}
{{ end }}

{{ with .Resources.GetMatch "styles.{scss,css}" }}
    {{- $pageCSS := . | toCSS $toCSSOptions | postCSS $postCSSOptions -}}
    {{- if not hugo.IsDevelopment -}}
        {{ $pageCSS = $pageCSS | minify | fingerprint }}
    {{- end -}}
    {{ with $pageCSS }}
      {{ if not hugo.IsDevelopment }}
        <link href="{{ .RelPermalink }}" rel="stylesheet" data-integrity="{{ .Data.Integrity }}" />
      {{ else }}
        <link href="{{ .RelPermalink }}" rel="stylesheet" />
      {{ end }}
    {{ end }}
{{ end }}

```

- Javascript is transpiled using `js.Build` (with minification for production builds). `fingerprint` is used for production builds as well (using the same conditional logic as the CSS above).

Below are the stats when completing a build (without the dev server):

```auto
| EN | EN-IN | JA | ZH | KO | DE | FR | ES | DA | IT | PT-BR | SV | FIL | HI | ID | NL | PL | RU | VI | CA | RO | TR | UK
-------------------+------+-------+------+------+------+------+------+------+------+------+-------+------+------+------+------+------+------+------+------+------+------+------+-------
  Pages | 1145 | 181 | 336 | 102 | 104 | 117 | 117 | 322 | 7 | 28 | 164 | 7 | 27 | 27 | 28 | 27 | 27 | 28 | 27 | 81 | 83 | 28 | 26
  Paginator pages | 49 | 2 | 16 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
  Non-page files | 2656 | 366 | 1050 | 338 | 357 | 419 | 419 | 536 | 34 | 182 | 309 | 34 | 182 | 182 | 201 | 182 | 182 | 201 | 182 | 357 | 375 | 80 | 70
  Static files | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556
  Processed images | 18 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
  Aliases | 26 | 12 | 27 | 10 | 10 | 13 | 13 | 17 | 1 | 1 | 12 | 1 | 2 | 2 | 2 | 1 | 1 | 2 | 2 | 19 | 18 | 7 | 7
  Cleaned | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0

```

What other information would be useful?

Thank you!

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [February 2, 2025, 3:37am UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/6 "2025-02-02T03:37:09Z")

</div>

Operating system?

---

<div class="post-metadata">

**Author:** ![AlanBreck](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/alanbreck/32/11694_2.png) [@AlanBreck](https://discourse.gohugo.io/u/AlanBreck)\
**Post date:** [February 2, 2025, 4:27am UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/7 "2025-02-02T04:27:20Z")

</div>

macOS 15.3

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [February 2, 2025, 11:53am UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/8 "2025-02-02T11:53:41Z")

</div>

> [@AlanBreck](#):
>
> ```auto
> Static files | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556 | 2556
> 
> ```

How big are your “static files”? Could you try starting the server without the static directory? (e.g. renaming it to something else).

---

<div class="post-metadata">

**Author:** ![AlanBreck](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/alanbreck/32/11694_2.png) [@AlanBreck](https://discourse.gohugo.io/u/AlanBreck)\
**Post date:** [February 3, 2025, 4:11pm UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/9 "2025-02-03T16:11:42Z")

</div>

Tried renaming the `static` folder, but the initial build for starting the dev server still took ~15mins.

The `static` folder is about 144.5MB. The largest file is about 27MB, second largest is 10.25MB, 23 files are between 1MB and 8MB, and the remaining ~5,000 files are under 1MB.

---

<div class="post-metadata">

**Author:** ![irkode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/irkode/32/26135_2.png) [@irkode](https://discourse.gohugo.io/u/irkode)\
**Post date:** [February 3, 2025, 5:31pm UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/10 "2025-02-03T17:31:05Z")

</div>

just like digging in the dark…

> [@davidsneighbour](#):
>
> Run the [server](https://gohugo.io/commands/hugo_server/) with `--templateMetrics` and `--templateMetricsHints` and `--logLevel debug`

the full logfile for a second eye to look on may reveal some hidden insights. share it.

just thinking out loud:

large json datasets you are manipulating? map merges? os.Readfile and evaluating content? complex templates with lot of code?

> [@AlanBreck](#):
>
> initial build for starting the dev server

whats after the initial run. stop server and next will be fast?

clear all caches and start with fresh clone

hw? disk? memory?

segments config might help to pinpoint.

running hugo server with the production environment also slow? what differences in config between additionally to the above.

any sourrounding steps or really just call hugo

maybe build on another machine. maybe clear all hugo caches, and start with a fresh clone…

.a second foreign build and check might be helpful…

impossible to track that down without access

you can share privately by temporary add read access..

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [February 3, 2025, 5:31pm UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/11 "2025-02-03T17:31:53Z")

</div>

> [@AlanBreck](#):
>
> Tried renaming the `static` folder, but the initial build for starting the dev server still took ~15mins.

OK, can you post the output of the starting the server with `hugo server --logLevel info` in here?

---

<div class="post-metadata">

**Author:** ![AlanBreck](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/alanbreck/32/11694_2.png) [@AlanBreck](https://discourse.gohugo.io/u/AlanBreck)\
**Post date:** [February 4, 2025, 7:41pm UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/12 "2025-02-04T19:41:40Z")

</div>

Thank you all for your continued assistance.

@bep, here’s a Gist with the output for `hugo server --logLevel info`:  
[https://gist.githubusercontent.com/AlanBreck/4b404a0d17156c3dbc2347dd6904e86e/raw/44db4626077656cbd7e5b99873b577125788c40a/output.txt](https://gist.githubusercontent.com/AlanBreck/4b404a0d17156c3dbc2347dd6904e86e/raw/44db4626077656cbd7e5b99873b577125788c40a/output.txt)

@irkode, here’s a Gist with the output from `hugo server --templateMetrics --templateMetricsHints --logLevel debug`  
[https://gist.githubusercontent.com/AlanBreck/4b404a0d17156c3dbc2347dd6904e86e/raw/44db4626077656cbd7e5b99873b577125788c40a/output-verbose.txt](https://gist.githubusercontent.com/AlanBreck/4b404a0d17156c3dbc2347dd6904e86e/raw/44db4626077656cbd7e5b99873b577125788c40a/output-verbose.txt)

> whats after the initial run. stop server and next will be fast?

Unfortunately, it’s no different when running, stopping, and then starting again.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [February 4, 2025, 8:10pm UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/13 "2025-02-04T20:10:02Z")

</div>

I see lots of lines like this in your log:

```auto
INFO dynacache: adjusted partitions' max size evicted 748 numGC 94 limit 4.00 GB alloc 4.15 GB totalAlloc 25.80 GB

```

Can you:

1. Check if you see simllar log lines when running `hugo --logLevel info`?
2. Can you try to set Hugo’s memory limit to something bigger and try again., e.g.`export HUGO_MEMORYLIMIT=8` and try again (8 GB).

I don’t have a good explanation as to why this happens in the server and not when building, but there’s something that “eats” memory somewhere, and that makes the cache much less useful.

---

<div class="post-metadata">

**Author:** ![irkode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/irkode/32/26135_2.png) [@irkode](https://discourse.gohugo.io/u/irkode)\
**Post date:** [February 6, 2025, 7:32am UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/14 "2025-02-06T07:32:18Z")

</div>

yepp and a lot of memory consumption \>30GB - what about Stats while processing? CPU Cores, MEM

I see lots of postcss complains - and supposedly 14 executions what happens if you skip that, and maybe minimize.

reminds me, there where more points in my post - machine stats, mem, …

what about comparing the results of using `hugo server` and `hugo` with any config

```auto
* `hugo --environment development`
* `hugo --environment production` <-- default
* `hugo server --environment production`
* `hugo server --environment development` <-- default

```

- a line like that:

- with template metrics you have  
for example `>100.000` calls to GetLink which sum up to a minute…

- you have much more pages and files in EN site do you merge missing pages…

all that said:

> I think that all (and things we do not know) play together to get such a result
> 
> imho that won’t work out here with some extracts from your site and log files… one who is willing to analyze and pin that down needs a full repo to do.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [February 6, 2025, 10:21am UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/15 "2025-02-06T10:21:17Z")

</div>

As to TailwindCSS, I would highly recommend to upgrade to TailwindCSS v4 (recently released) and use the setup as outlined in:

> **[hugo-testing-tailwindcss-v4/tailwindcss-cli-defer at main ·...](https://github.com/bep/hugo-testing-tailwindcss-v4/tree/main/tailwindcss-cli-defer)**
>
> A test/demo repo. Contribute to bep/hugo-testing-tailwindcss-v4 development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![AlanBreck](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/alanbreck/32/11694_2.png) [@AlanBreck](https://discourse.gohugo.io/u/AlanBreck)\
**Post date:** [February 11, 2025, 3:03am UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/16 "2025-02-11T03:03:36Z")

</div>

I’ve continued to do more testing. Have yet to determine anything conclusive, but three details stand out as being noteworthy:

1. I currently have 23 languages configured in my `config/_default/languages.toml` file. When reducing this to two, but not deleting any of the localized content files themselves, the build times for `hugo server` go back to relatively normal.
2. Using `hvm`, I tested with various versions to pinpoint when the behavior begins. I get pretty normal build times with `hugo server` for `0.140.1`, but the really long builds for `hugo server` start with `0.140.2`. I’ve tried clearing caches and switching back and forth several times to confirm, and it’s consistently reproducible that `0.140.1` is normal whereas `0.140.2` is not.
3. When comparing the output of running `hugo server --templateMetrics --templateMetricsHints --logLevel debug` using `0.142.0` against the output from `0.119.0`, I’m seeing a massive difference in the number of times `postcss: use config file ...` appears. For `0.119.0` (and in fact `0.140.1`) it’s **\<50** (here are [the logs from `0.119.0`](https://gist.githubusercontent.com/AlanBreck/4b404a0d17156c3dbc2347dd6904e86e/raw/5bb24a616500a339018b04e4f0a41e3777ac8d08/output-verbose-119.txt)); for `0.142.0` it’s **859** instances.

> reminds me, there where more points in my post - machine stats, mem, …

I’m running an Apple M1 Pro with 16GB of RAM.

> what about comparing the results of using `hugo server` and `hugo` with any config

I haven’t thoroughly tested this yet, but did a bit of testing here with no discernible differences.

---

<div class="post-metadata">

**Author:** ![irkode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/irkode/32/26135_2.png) [@irkode](https://discourse.gohugo.io/u/irkode)\
**Post date:** [February 11, 2025, 7:07am UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/17 "2025-02-11T07:07:57Z")

</div>

> [@AlanBreck](#):
>
> with 16GB of RAM.

with hugo telling to need 30GB.. will result in much swapping out… as @bep said you are loosing memory.

> [@AlanBreck](#):
>
> seeing a massive difference in the number of times `postcss`

turn it off

your css layout calles it three times for and something like section specific stuff…maybe a concurrency problem scanning things twice…

> [@irkode](#):
>
> all that said: …

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [February 11, 2025, 10:37am UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/18 "2025-02-11T10:37:33Z")

</div>

Just a quick note of reference,

I had, by accident, this set in my OS env on my MacBook for 3 months without thinking about it:

```auto
HUGO_MEMORYLIMIT=1

```

And I build some pretty big Hugo sites.

Which means max 1 GB. If Hugo uses more than that it will try to free memory by evicting things from cache. This allows e.g. building sites pulling in thousands of big JSON files via `resources.Get "foo.json" | transform.Unmarshal` without needing a massive amount of ram.

By default we set aside 1/4 of the system ram. In my case that is 32/4 =\> 8GB. In your case that is 16/4 =\> 4GB, which should be plenty.

But there are some very unusual stuff going on that is impossible for us to debug further without access to the full source code.

That said, I would strongly recommend you start by upgrading to TailwindCSS v4 and get rid of PostCSS in your setup.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [February 11, 2025, 2:43pm UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/19 "2025-02-11T14:43:14Z")

</div>

> [@AlanBreck](#):
>
> the really long builds for `hugo server` start with `0.140.2`

There weren’t many changes in [v0.140.2](https://github.com/gohugoio/hugo/releases/tag/v0.140.2), but [4e52be8](https://github.com/gohugoio/hugo/commit/4e52be8b90dca178ef8a0545e8bb3d0fe9424437) caught my attention because it relates to how we generate the `hugo_stats.json` file.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [February 11, 2025, 3:16pm UTC](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344/20 "2025-02-11T15:16:40Z")

</div>

> [@jmooring](#):
>
> There weren’t many changes in [v0.140.2](https://github.com/gohugoio/hugo/releases/tag/v0.140.2), but [4e52be8](https://github.com/gohugoio/hugo/commit/4e52be8b90dca178ef8a0545e8bb3d0fe9424437) caught my attention because it relates to how we generate the `hugo_stats.json` file.

None of those links makes much sense to me, but you’re probly right in that this is a rebuild-loop that comes from hugo\_stats.json file changing.

Again, I don’t know what the original project is configured, but it’s worth testing if remove any watch/mount of the hugo\_stats.json file makes the server start normally.

[Next page](https://discourse.gohugo.io/t/extremely-slow-dev-server/53344.md?page=2)
