Upgrade to 2.28.1, 502 on image upload

Just updated to the latest version and everything is working except cannot upload images to posts. Usually I’d say this is a permissions issue, but the error I’m getting is a 502 Bad Gateway. Note this is only when uploading images, not when saving posts or anything.

  • What version of Ghost are you using?
    2.28.1

  • What configuration?
    DO , but manually installed. Running for ~2 years.

  • What browser?
    5xx error so not relevant

  • What errors or information do you see in the console?

      Failed to load resource: the server responded with a status of 502 (Bad Gateway)
      vendor.min-d0058a79a7024ae97934122ff0ae2495.js:2386 Uncaught TypeError: Cannot read property 'url' of undefined
          at vendor.min-d0058a79a7024ae97934122ff0ae2495.js:10220
          at e.value (vendor.min-d0058a79a7024ae97934122ff0ae2495.js:5760)
          at r.updateSrc (vendor.min-d0058a79a7024ae97934122ff0ae2495.js:10220)
          at e.r._join (vendor.min-d0058a79a7024ae97934122ff0ae2495.js:4286)
          at e.r.join (vendor.min-d0058a79a7024ae97934122ff0ae2495.js:4251)
          at h (vendor.min-d0058a79a7024ae97934122ff0ae2495.js:3101)
          at vendor.min-d0058a79a7024ae97934122ff0ae2495.js:1403
          at a (vendor.min-d0058a79a7024ae97934122ff0ae2495.js:3010)
          at r.onComplete (vendor.min-d0058a79a7024ae97934122ff0ae2495.js:1403)
          at r.<anonymous> (ghost.min-8cb104ab0899e4efc1458f3d804f9220.js:495)
      /ghost/api/canary/admin/posts/5d5979893e583d15add332b7/:1 Failed to load resource: the server responded with a status of 502 (Bad Gateway)
      2/ghost/api/canary/admin/images/upload/:1 Failed to load resource: the server responded with a status of 502 (Bad Gateway)
      vendor.min-d0058a79a7024ae97934122ff0ae2495.js:850 POST https://www.website/ghost/api/canary/admin/images/upload/ 502 (Bad Gateway)
      send @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:850
      ajax @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:827
      _makeRequest @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:8102
      _makeRequest @ ghost.min-8cb104ab0899e4efc1458f3d804f9220.js:1416
      r @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:2627
      request @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:8096
      post @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:8111
      generateRequest @ ghost.min-8cb104ab0899e4efc1458f3d804f9220.js:170
      (anonymous) @ ghost.min-8cb104ab0899e4efc1458f3d804f9220.js:160
      t.invoke @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:4218
      t.flush @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:4210
      t.flush @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:4223
      r._end @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:4285
      r.end @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:4240
      r._run @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:4287
      r._join @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:4286
      r.join @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:4251
      h @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:3101
      (anonymous) @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:2788
      a @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:3010
      handleEvent @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:2788
      handleEvent @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:2701
      (anonymous) @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:2726
      dispatch @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:642
      b.handle @ vendor.min-d0058a79a7024ae97934122ff0ae2495.js:637
    

Ghost log shows me:

[2019-08-18 16:37:35] INFO "GET /ghost/assets/img/contributors/kevinansfield-925606c55bc2f3f2f05c0fa58b953ad1.jpeg" 200 2ms
[2019-08-18 16:37:35] INFO "GET /ghost/assets/img/contributors/GeorginaLusby-6cea5defddee3c4ea7320e580521e832.jpeg" 200 1ms
[2019-08-18 16:38:31] INFO "GET /ghost/api/canary/admin/posts/?limit=30&page=1&filter=status%3A%5Bdraft%2Cscheduled%2Cpublished%5D" 200 233ms
[2019-08-18 16:38:33] INFO "GET /ghost/api/canary/admin/posts/5d5979893e583d15add332b7/?status=all" 200 45ms
[2019-08-18 16:38:33] INFO "GET /ghost/api/canary/admin/tags/?limit=all" 200 70ms
[2019-08-18 16:38:33] INFO "GET /ghost/api/canary/admin/users/?limit=all&include=roles" 200 69ms
[2019-08-18 16:38:53] INFO Ghost is running in production...
[2019-08-18 16:38:53] INFO Your site is now available on https://www.website/
[2019-08-18 16:38:53] INFO Ctrl+C to shut down
[2019-08-18 16:38:53] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-08-18 16:38:53] WARN Tries: 0
[2019-08-18 16:38:53] WARN Retrying...
[2019-08-18 16:38:53] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-08-18 16:38:53] WARN Tries: 1
[2019-08-18 16:38:53] WARN Retrying...
[2019-08-18 16:38:54] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-08-18 16:38:54] WARN Tries: 2
[2019-08-18 16:38:54] WARN Retrying...
[2019-08-18 16:38:54] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-08-18 16:38:54] INFO Ghost boot 3.848s

I’m guessing this is some kind of Nginx->Ghost proxy config issue?

Ghost doctor shows everything is ok, and like I say, I can browse the site and save posts fine, just cannot upload images.

UPDATE:
So it looks similar to this issue: 502 Error after updating to v2 - #9 by tonyxu
but also Im getting an issue similar to:

UPDATE 2:
so the blog seems to be restarting at seemingly random intervals.

ps aux | grep node

gives me:
ghost 1880 22.4 9.1 1896148 93072 ? Sl 07:58 0:03 /usr/bin/node current/index.js

after a crash the pid changes. (as expected)…

My version history is:
1.23.0 1.25.5 2.0.2 2.28.1 2.4.0

I’ve tried disabling AMP and removed all old versions.

UPDATE 3:
running

ghost run

Everything works. I can upload images , and the node process stays up.

Any ideas why ghost run would be fine but ghost start not?

1 Like

Hi there. Sorry you’re having trouble. Might be worth keeping track of the other thread in the hope their issue is the same as yours:

Thanks.

My current solution is running:

sudo NODE_ENV=production nohup node current/index.js &

To keep it running in the same way ghost run does.

any attempt to run ghost start just seems to cause issues with the 502s due to the process dying and restarting.

1 Like

@kiksy did you have a chance to figure out the problem? Did you try bumping the file size limit as advised in the GH issue:

Btw, closed the GH issue to keep it clean there. We can reopen it if the bug is confirmed to be a Ghost core issue :wink:

1 Like

I’m having the same issue as the one mentioned by @naz.

I’m running ghost 2.31.1 with node 10.16.0.

Everything about running ghost seems to be working. Except when I try to upload images, then I get a message in ghost saying “something went wrong :(”. Inspecting the page only shows the following error “POST https://andreborud.com/ghost/api/canary/admin/images/upload/ 502” with no more info.

I have checked logs in ghost and nginx, no specific errors linked with this.

Uploading a theme however works fine with now complaints.

just tried stopping ghost and starting it with ghost run instead, then uploading the image works without problems.

What I have tried is to give all permissions to the ghost user of the content folder. Disable SELinux. And some different NGINX configurations. Nothing works. But ghost run did work. What does ghost run do differently over ghost start?

@naz what information could I add to make the issue worthy of reopening?

I haven’t had chance to look into this any further. For me the upload issue was a bit of a red herring. The using ‘ghost run’ causes the process to die and restart regularly. Trying to upload seems to trigger a process death, but it will die without trying to upload, it’s just less noticeable as the process starts up so quick. ‘ghost run’ does not cause this behavior for me.

Going to close this topic as it’s a duplicate of 502 Error after updating to v2 - #24 by ekerstein - please post there if you have more info to share.