Could not save attachment data from stream error when adding attachments to issue in Jira server

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

Problem 1

When attempting to attach files to an issue, the following error message is thrown

1 An error occurred while attaching name.ext: Could not save attachment data from stream
(Auto-migrated image: description temporarily unavailable)

Nothing is thrown in the logs when this is happening

Problem 2

When attempting to attach files to an issue, the file may seem to successfully attach but cannot be opened, or it won't successfully attach at all.

The following is thrown in the atlassian-jira.log

1 2 2015-07-13 17:13:09,853 http-bio-6471-exec-5 WARN spiderman xxx xxx 127.0.0.1 /secure/AttachFile.jspa [jira.issue.managers.DefaultAttachmentManager] Got exception while saving attachment in attachment store. Exception: Unable to create target file <JIRA Home>/data/attachments/TEST/TEST-4/10200

OR

1 Caused by: java.io.FileNotFoundException: /var/atlassian/application-data/jira/data/attachments/ABC/ABC-123/10000 (No such file or directory)

Problem 3

When uploading attachments the UI displays the error "An internal error has occurred. Please contact your administrator."

(Auto-migrated image: description temporarily unavailable)

The browser console (inside its developer tools panel) might show an error message 'ERR_CONNECTION_RESET' similar to this:

1 2 3 4 ... POST https://<JIRA_BASE_URL>/rest/internal/2/AttachTemporaryFile?filename=data-1615234721693.csv ... net::ERR_CONNECTION_RESET

Diagnosis

Diagnosis 1

Attachments are disabled upon JIRA start up and the following stack trace is thrown during JIRA start up

1 2 2015-05-13 23:05:44,404 localhost-startStop-1 ERROR [atlassian.jira.upgrade.ConsistencyCheckImpl] Attachments are turned on, Errors: {} Error Messages: [attachment path [<JIRA Home>/caches/tmp_attachments] invalid] - disabling attachments

Diagnosis 2

Attaching files to specific issue tickets fail, but other tickets are successful.

Diagnosis 3

HTTP dump logs (enabled in the page Cog Icon > Logging and profiling) will show the request data having zero bytes in size:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 10.218.62.110 o772x68058x3 HECTMP1 [02/Aug/2021:12:52:31 -0400] "POST https://<JIRA_BASE_URL>/rest/internal/2/AttachTemporaryFile HTTP/1.1" 500 119 18.9060 "https://<JIRA_BASE_URL>/browse/PROJECT-6" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" "1homd4c" ___ Request _____________________________________________________ Request URL Parameters : filename=web.xml size=25453881 atl_token=BEWN-74VL-4IH7-TGIK_467e29e204835444e2020d6dd1d4d8a6a4721d89_lin formToken= issueId=483082 (...) Request Data (0 bytes). ___ Response ____________________________________________________ Response HTTP Headers : X-AUSERNAME=HECTMP1 Cache-Control=no-cache, no-store, no-transform Content-Type=application/json Access-Control-Allow-Origin=https://<JIRA_BASE_URL> Access-Control-Allow-Credentials=true Access-Control-Expose-Headers=Origin, Authorization, Content-Type Response Data (total 119 bytes) : {"errorMessage":"An error occured while attaching web.xml: Could not save attachment data from stream."}

Cause

Cause 1

  • In the Data Center environment, one of the node attachment options is disabled.

  • The user starting JIRA does not have appropriate permissions to the <JIRA Home>/caches/tmp_attachments directory.

  • There are some misconfigurations in the server.xml (in this case use the default configuration back).

  • The attachment health check is getting the error:

    1 2 3 4 Name: Attachments Is healthy: false Failure reason: The attachment (xxxx.docx) for issue (TEST-xxx) could not be read. Severity: MAJOR

Cause 2

Every issue will have their own directory for attachments (<JIRA Home>/data/attachments/TEST/TEST-4). These directories are not owned by the user currently used to start JIRA. It is possibly owned by root. This can happen if at one point, your JIRA instance was started by user root. When a new directory is created in this session, it will be owned by root. If JIRA is started by the correct user (eg. jira) the next time, this user won't have permission to access the directory created by root hence causing problems attaching files for this particular issue

Another possibility for Problem 2 would be antivirus software preventing the files to be written.

Cause 3

Something in between the browser and Jira is tampering with the contents of the POST request used to upload the attachment. Some examples include:

  • Security software, such as antivirus.

  • Firewalls and WAFs (web application firewalls).

  • VPNs.

  • Browser extensions.

Cause 4

Data encryption been done could be a problematic area.

Resolution

  • Validate server.xml configuration has no missing default parameters as shown in the running Jira application with SSL or HTTPS

  • Make sure the Enable attachments option is set to ON.

  • Fix the permissions for the affected directory:

    • In Linux, you can fix the permission for the entire JIRA Home directory by running the following command in the terminal

      1 2 chown -R jira:jira /var/atlassian/application-data/jira chmod -R 755 /var/atlassian/application-data/jira
    • Fix the temporary attachment in the Jira Home directory

      1 2 chmod -R u=rwx,g=rx,o=rx /var/atlassian/application-data/jira/caches chmod -R u=rwx,g=rx,o=rx /var/atlassian/application-data/jira/caches/tmp_attachments

      ℹ️ The command above assumes the user starting JIRA is jira and that you used the installer, hence the default JIRA Home path. If your user has a different name, use it instead of jira and if you used a custom path, fix the permissions for your custom JIRA Home directory.

  • If there's antivirus software present, try disabling it to check if the issue goes away. If it does, configure it in a way to allow the attachments to be saved.

  • If the /data/attachments/ directory is located on a mounted storage location, please also check the available disk space and mounting options to ensure that it is optimized.

  • Might want to disable or rectify data encryption issue under local and share home as well.

Updated on April 15, 2025

Still need help?

The Atlassian Community is here for you.