# Import Users via CSV

**URL:** https://meta.discourse.org/t/import-users-via-csv/391695
**Category:** Support
**Created:** [December 18, 2025, 7:47pm UTC](https://meta.discourse.org/t/import-users-via-csv/391695 "2025-12-18T19:47:55Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Timelord](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@Timelord](https://meta.discourse.org/u/Timelord)
#### Post date: [December 18, 2025, 7:47pm UTC](https://meta.discourse.org/t/import-users-via-csv/391695/1 "2025-12-18T19:47:55Z")

</div>

I know there is a ‘frontend’ way to invite users via CSV, however that will not work in my case, as it will send an email to the thousands of people who will be added to the site.

When trying to add it via the CLI, I get the following errors.

/var/www/discourse# rails runner script/import\_scripts/csv\_importer.rb /var/www/discourse/tmp/users.csv  
Loading existing groups…  
Loading existing users…  
Loading existing categories…  
Loading existing posts…  
Loading existing topics…  
File doesn’t exist: /var/www/discourse/tmp/emails.csv  
File doesn’t exist: /var/www/discourse/tmp/custom\_fields.csv  
bundler: failed to load command: script/rails (script/rails)  
/var/www/discourse/script/import\_scripts/csv\_importer.rb:29:in `initialize': undefined method `headers’ for nil (NoMethodError)

```plaintext
@imported_custom_fields_names = @imported_custom_fields.headers.drop(1)
                                                       ^^^^^^^^

```

Any thoughts on what could be going on?

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [December 18, 2025, 8:22pm UTC](https://meta.discourse.org/t/import-users-via-csv/391695/2 "2025-12-18T20:22:32Z")

</div>

> [@Timelord](#):
>
> rails runner script/import\_scripts/csv\_importer.rb

This script is a [migration script](https://meta.discourse.org/t/migrate-from-another-forum-to-discourse/16616), it’s not intended for doing the singular task of adding users.

Do you just want to create a larger number of real user accounts, or are they for testing?

---

<div class="post-metadata">

### Author: ![Timelord](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@Timelord](https://meta.discourse.org/u/Timelord)
#### Post date: [December 18, 2025, 11:03pm UTC](https://meta.discourse.org/t/import-users-via-csv/391695/3 "2025-12-18T23:03:51Z")

</div>

Aha! I saw importer, not migration! Thanks for the tip.

I want to import a large amount of users via CSV

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 19, 2025, 12:22am UTC](https://meta.discourse.org/t/import-users-via-csv/391695/4 "2025-12-19T00:22:36Z")

</div>

Import and migrate here are mostly synonyms.

It should do the job of creating all of those users (they won’t have passwords, so they’ll need to get one, probably by having an email sent to them).

You’ll likely need to understand a bit about programming to make it work.

---

<div class="post-metadata">

### Author: ![Timelord](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@Timelord](https://meta.discourse.org/u/Timelord)
#### Post date: [December 19, 2025, 1:00am UTC](https://meta.discourse.org/t/import-users-via-csv/391695/5 "2025-12-19T01:00:15Z")

</div>

First off - happy birthday.

I have next to no programming skills. I assumed it would be as simple as kicking off the import.rb file ‘pointed’ at the users.csv.

The errors it output make exactly zero sense to me. I looked at line 29 of the import script and it referenced headers, so I assumed it meant the columns of the csv file, so I spent some time mucking with that, to no avail.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 19, 2025, 1:11am UTC](https://meta.discourse.org/t/import-users-via-csv/391695/6 "2025-12-19T01:11:05Z")

</div>

Well, you didn’t get very far since it never even opened your csv.

> [@Timelord](#):
>
> File doesn’t exist: /var/www/discourse/tmp/emails.csv

It’s one of those frustrating things where it could take 30 seconds or hours.

But you might try copying the file to there. It’s tricky because it’s one place in the file system of the computer and another inside the container. Once you solve that you can start mucking with the column headings.

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [December 19, 2025, 1:33am UTC](https://meta.discourse.org/t/import-users-via-csv/391695/7 "2025-12-19T01:33:49Z")

</div>

> [@Timelord](#):
>
> that will not work in my case, as it will send an email to the thousands of people who will be added to the site

Sometimes there’s an easy solution to the _original problem_\[1\].

Disable emails, import the users, then re-enable emails.

* * *

1. see x-y problem

---

<div class="post-metadata">

### Author: ![Timelord](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@Timelord](https://meta.discourse.org/u/Timelord)
#### Post date: [December 19, 2025, 1:34am UTC](https://meta.discourse.org/t/import-users-via-csv/391695/8 "2025-12-19T01:34:40Z")

</div>

Aha - but the issue here, is that I _think_ the importer picked up the users.csv.

I don’t have or want to import emails.csv etc.

Or is this a multipart importer? Where users (names) are in one csv, and the amils are in another csv (emails.csv)

It looks like it is finding the users.csv file as it is not barfing an error about that one.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 19, 2025, 11:05am UTC](https://meta.discourse.org/t/import-users-via-csv/391695/9 "2025-12-19T11:05:48Z")

</div>

> [@Timelord](#):
>
> Or is this a multipart importer? Where users (names) are in one csv, and the amils are in another csv (emails.csv)

I have not looked at the code lately, but users csv needs to have the email address. The topics and posts are on another csv.

---

<div class="post-metadata">

### Author: ![Timelord](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@Timelord](https://meta.discourse.org/u/Timelord)
#### Post date: [December 19, 2025, 2:57pm UTC](https://meta.discourse.org/t/import-users-via-csv/391695/10 "2025-12-19T14:57:12Z")

</div>

OK, so I am in the right track. I will keep plugging away at this.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 19, 2025, 3:39pm UTC](https://meta.discourse.org/t/import-users-via-csv/391695/11 "2025-12-19T15:39:56Z")

</div>

Here’s where the filename gets set:

```plaintext
  CSV_FILE_PATH = ENV["CSV_USER_FILE"] || "/var/www/discourse/tmp/users.csv"

```

So either put the file there, or set ENV variable `CSV_USER_FILE` to wherever you put the file.

Oh, but the first thing the script does is read in ALL of the CSVs it expects (all of those @… = `load_csv` lines), so you’ll need to comment out or delete the ones you don’t want. And the `import_users` looks at custom field data, so you need to change that too.

If that’s not enough of a hint, and you’ve got a budget, email (in my profile) me a number and I’ll see what I can find a way to help you for that number.
