# Internal server error when making polls

**URL:** https://meta.discourse.org/t/internal-server-error-when-making-polls/119136
**Category:** Support
**Created:** [May 31, 2019, 12:05am UTC](https://meta.discourse.org/t/internal-server-error-when-making-polls/119136 "2019-05-31T00:05:09Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Ellibereth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ellibereth/32/202896_2.png) [@Ellibereth](https://meta.discourse.org/u/Ellibereth)
#### Post date: [May 31, 2019, 12:05am UTC](https://meta.discourse.org/t/internal-server-error-when-making-polls/119136/1 "2019-05-31T00:05:10Z")

</div>

I’m getting an internal server error when making topics and posts with polls in them on my instance. The topic/post still gets created but the composer content doesn’t get cleared.

On testing it doesn’t seem to be happening here - I tried on [safe mode](https://meta.discourse.org/t/53504?silent=true) with only official plugins on in my instance and it’s still happening though.

Which plugin is in charge of creating polls - not seeing one in the list? When I go to [safe mode](https://meta.discourse.org/t/53504?silent=true) with everything off the poll option disappears all together.

EDIT: Also seems to be working properly on try.discourse with only official plugins available. What reasons would there be for the [safe mode](https://meta.discourse.org/t/53504?silent=true) behavior there and on my instance to be different?

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [May 31, 2019, 12:51am UTC](https://meta.discourse.org/t/internal-server-error-when-making-polls/119136/2 "2019-05-31T00:51:18Z")

</div>

Anything happening in the logs?

---

<div class="post-metadata">

### Author: ![Ellibereth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ellibereth/32/202896_2.png) [@Ellibereth](https://meta.discourse.org/u/Ellibereth)
#### Post date: [May 31, 2019, 1:12am UTC](https://meta.discourse.org/t/internal-server-error-when-making-polls/119136/3 "2019-05-31T01:12:49Z")

</div>

```plaintext
ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_polls_on_post_id_and_name"
DETAIL: Key (post_id, name)=(74475, poll) already exists.
: INSERT INTO "polls" ("post_id", "created_at", "updated_at") VALUES (74475, '2019-05-31 01:11:30.464491', '2019-05-31 01:11:30.464491') RETURNING "id")
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.0.2/lib/patches/db/pg.rb:72:in `async_exec_params'

```

```plaintext
Failed to handle exception in exception app middleware : PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_polls_on_post_id_and_name"
DETAIL: Key (post_id, name)=(74475, poll) already exists.
: INSERT INTO "polls" ("post_id", "created_at", "updated_at") VALUES (74475, '2019-05-31 01:11:30.464491', '2019-05-31 01:11:30.464491') RETURNING "id"

```

---

<div class="post-metadata">

### Author: ![Ellibereth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ellibereth/32/202896_2.png) [@Ellibereth](https://meta.discourse.org/u/Ellibereth)
#### Post date: [May 31, 2019, 10:15pm UTC](https://meta.discourse.org/t/internal-server-error-when-making-polls/119136/4 "2019-05-31T22:15:24Z")

</div>

Just realized that polls are part of core and not a plugin. Doesn’t that mean that the poll option should appear in safe-mode with everything off, or am I misunderstanding how [safe mode](https://meta.discourse.org/t/53504?silent=true) works?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [May 31, 2019, 10:33pm UTC](https://meta.discourse.org/t/internal-server-error-when-making-polls/119136/5 "2019-05-31T22:33:17Z")

</div>

Polls are added through the Poll plugin. It is one of a few plugins that comes bundled with Discourse. You can see those plugins here: [discourse/plugins at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/tree/master/plugins).

To enter safe-mode, but keep the poll plugin enabled, deselect ‘Disable all plugins’ and make sure that ‘Disable unofficial plugins’ is selected when you enter safe-mode.

---

<div class="post-metadata">

### Author: ![Ellibereth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ellibereth/32/202896_2.png) [@Ellibereth](https://meta.discourse.org/u/Ellibereth)
#### Post date: [May 31, 2019, 10:36pm UTC](https://meta.discourse.org/t/internal-server-error-when-making-polls/119136/6 "2019-05-31T22:36:41Z")

</div>

Mmm I tried that. If the error is happening in [safe mode](https://meta.discourse.org/t/53504?silent=true) with only official plugins does it imply that it has to be one of the official plugins I have causing the error? I’m mainly struggling because I get the error in [safe mode](https://meta.discourse.org/t/53504?silent=true) with only official plugins on my instance but not on try.discourse.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [May 31, 2019, 10:57pm UTC](https://meta.discourse.org/t/internal-server-error-when-making-polls/119136/7 "2019-05-31T22:57:13Z")

</div>

From looking at the error message you have posted, it seems that the problem is with the post on your site with the id `74475`. There are probably two polls in the post with the same name.

You could try finding that post by entering your rails console and then run:

```ruby
Post.find(74475)

```

See if there are two polls in the post’s `raw` field that have the same name.

---

<div class="post-metadata">

### Author: ![Ellibereth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ellibereth/32/202896_2.png) [@Ellibereth](https://meta.discourse.org/u/Ellibereth)
#### Post date: [June 4, 2019, 10:35pm UTC](https://meta.discourse.org/t/internal-server-error-when-making-polls/119136/8 "2019-06-04T22:35:25Z")

</div>

The cause for this was one of our custom plugins. It’s somehow effecting the site even through [safe mode](https://meta.discourse.org/t/53504?silent=true).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 5, 2019, 2:47pm UTC](https://meta.discourse.org/t/internal-server-error-when-making-polls/119136/9 "2019-06-05T14:47:57Z")

</div>

Server side changes in plugins cannot be disabled via [safe mode](https://meta.discourse.org/t/53504?silent=true).

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [July 5, 2019, 2:48pm UTC](https://meta.discourse.org/t/internal-server-error-when-making-polls/119136/10 "2019-07-05T14:48:00Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
