502 Error after updating to v2

Getting 502 errors while trying to upload images to our ghost blog. Anyone has seen this error before? Many thanks!

  • Version of Ghost: v2.25 (and v2.27)

  • Configuration:
    DigitalOcean one-click installation
    OS: Ubuntu, v16.04
    Node Version: v10.16.0
    Ghost-CLI Version: 1.11.0

  • Error message in console
    vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:850 POST https://www.domain.com/blog/ghost/api/v2/admin/images/upload/ 502
    send @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:850
    ajax @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:827
    _makeRequest @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8043
    _makeRequest @ ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:1416
    r @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2618
    request @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8037
    post @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8052
    _uploadFile (task) @ ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:495
    _resumeGenerator @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8485
    _handleResolvedContinueValue @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8493
    _proceed @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8486
    _scheduleProceed @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8486
    _start @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8471
    _startTaskInstance @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8457
    _flushQueues @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8454
    schedule @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8447
    _performShared @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8513
    perform @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8512
    _uploadFiles (task) @ ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:493
    _resumeGenerator @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8485
    _handleResolvedContinueValue @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8493
    _proceed @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8486
    _scheduleProceed @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8486
    _start @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8471
    _startTaskInstance @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8457
    _flushQueues @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8454
    schedule @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8447
    _performShared @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8513
    perform @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8512
    _setFiles @ ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:485
    setFiles @ ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:485
    r._join @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4276
    r.join @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4241
    h @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:3091
    (anonymous) @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:1403
    a @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:3007
    (anonymous) @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:1403
    change @ ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:114
    trigger @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2767
    r @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2618
    r._run @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4277
    r._join @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4276
    r.join @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4241
    h @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:3091
    (anonymous) @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2781
    a @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:3007
    handleEvent @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2781
    handleEvent @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2694
    (anonymous) @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2719
    dispatch @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:642
    b.handle @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:637
    Show 21 more frames
    vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:10161 Uncaught TypeError: Cannot read property ā€˜urlā€™ of undefined
    at vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:10161
    at e.value (vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:5756)
    at r.updateSrc (vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:10161)
    at e.r._join (vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4276)
    at e.r.join (vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4241)
    at h (vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:3091)
    at vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:1403
    at a (vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:3007)
    at r.onComplete (vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:1403)
    at r. (ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:493)
    (anonymous) @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:10161
    value @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:5756
    updateSrc @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:10161
    r._join @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4276
    r.join @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4241
    h @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:3091
    (anonymous) @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:1403
    a @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:3007
    (anonymous) @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:1403
    _uploadFiles (task) @ ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:493
    _resumeGenerator @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8485
    _handleResolvedContinueValue @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8493
    _proceed @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8486
    t.invoke @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4208
    t.flush @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4200
    t.flush @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4213
    r._end @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4275
    r.end @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4230
    r._run @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4277
    r._join @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4276
    r.join @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4241
    h @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:3091
    (anonymous) @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8051
    l @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:558
    fireWith @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:559
    k @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:839
    (anonymous) @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:849
    load (async)
    send @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:849
    ajax @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:827
    _makeRequest @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8043
    _makeRequest @ ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:1416
    r @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2618
    request @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8037
    post @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8052
    _uploadFile (task) @ ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:495
    _resumeGenerator @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8485
    _handleResolvedContinueValue @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8493
    _proceed @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8486
    _scheduleProceed @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8486
    _start @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8471
    _startTaskInstance @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8457
    _flushQueues @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8454
    schedule @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8447
    _performShared @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8513
    perform @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8512
    _uploadFiles (task) @ ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:493
    _resumeGenerator @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8485
    _handleResolvedContinueValue @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8493
    _proceed @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8486
    _scheduleProceed @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8486
    _start @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8471
    _startTaskInstance @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8457
    _flushQueues @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8454
    schedule @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8447
    _performShared @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8513
    perform @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:8512
    _setFiles @ ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:485
    setFiles @ ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:485
    r._join @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4276
    r.join @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4241
    h @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:3091
    (anonymous) @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:1403
    a @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:3007
    (anonymous) @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:1403
    change @ ghost.min-abc057d4ff00a31ff766d6e04096d8c6.js:114
    trigger @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2767
    r @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2618
    r._run @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4277
    r._join @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4276
    r.join @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:4241
    h @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:3091
    (anonymous) @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2781
    a @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:3007
    handleEvent @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2781
    handleEvent @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2694
    (anonymous) @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:2719
    dispatch @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:642
    b.handle @ vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:637
    Show 48 more frames
    vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:850 PUT https://www.domain.com/blog/ghost/api/v2/admin/posts/5d499c8de15e026333fb5ef7/ 502

Can you share the output from the server side ghost logs? either ghost log or looking in the content/logs folder.

The server side log should have some detail of what the real issue is.

1 Like

thanks, will have a look now

ghost log looks all normal except occational bootstrap socket warning[2019-08-06 16:00:40] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED [2019-08-06 16:00:40] WARN Tries: 2 [2019-08-06 16:00:40] WARN Retrying... [2019-08-06 16:00:40] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED

content/logs/xxxx.error.log also doesnā€™t seem to have anything related:

Log message

{"name":"Log","hostname":"ghost-1gb-lon1-01","pid":22115,"level":50,"err":{"id":"ff065dd0-b7e2-11e9-b21e-27ab7c4b8eeb","domain":"https://www.perfocal.com/blog","code":"IMAGE_SIZE_URL",$ {"name":"Log","hostname":"ghost-1gb-lon1-01","pid":22115,"level":50,"err":{"id":"607105b0-b7ee-11e9-b21e-27ab7c4b8eeb","domain":"https://www.perfocal.com/blog","code":"IMAGE_SIZE_URL",$ {"name":"Log","hostname":"ghost-1gb-lon1-01","pid":22115,"level":50,"err":{"id":"17e6be20-b816-11e9-b21e-27ab7c4b8eeb","domain":"https://www.perfocal.com/blog","code":"IMAGE_SIZE_URL",$ {"name":"Log","hostname":"ghost-1gb-lon1-01","pid":22115,"level":50,"err":{"id":"a895ed60-b816-11e9-b21e-27ab7c4b8eeb","domain":"https://www.perfocal.com/blog","code":"IMAGE_SIZE_URL",$ {"name":"Log","hostname":"ghost-1gb-lon1-01","pid":25170,"level":50,"req":{"meta":{"requestId":"7ca10212-213d-433d-834c-7c10ee98f38b","userId":null},"url":"/users/me/?include=roles","m$ {"name":"Log","hostname":"ghost-1gb-lon1-01","pid":25170,"level":50,"req":{"meta":{"requestId":"93c137b0-30dd-410a-8997-f662aabdf89c","userId":null},"url":"/users/me/?include=roles","m$ {"name":"Log","hostname":"ghost-1gb-lon1-01","pid":25170,"level":50,"req":{"meta":{"requestId":"25088877-d99e-4a6c-9d05-f592701268de","userId":null},"url":"/users/me/?include=roles","m$ {"name":"Log","hostname":"ghost-1gb-lon1-01","pid":25170,"level":50,"req":{"meta":{"requestId":"d259f43b-a17f-47e6-8a71-de3a6f3b94ad","userId":null},"url":"/users/me/?include=roles","m$ {"name":"Log","hostname":"ghost-1gb-lon1-01","pid":25395,"level":50,"req":{"meta":{"requestId":"ebc8c1f0-b85e-11e9-b180-57ed8e51868a","userId":null},"url":"/posts/?limit=30&page=1&filt$ {"name":"Log","hostname":"ghost-1gb-lon1-01","pid":25640,"level":50,"req":{"meta":{"requestId":"93f45ce0-b85f-11e9-b476-097d946872ea","userId":"5c6c09a7c01ffe7017976daf"},"url":"/posts$ {"name":"Log","hostname":"ghost-1gb-lon1-01","pid":25818,"level":50,"req":{"meta":{"requestId":"b8ca7270-b85f-11e9-b7ec-4d4e6d0b53ce","userId":"5c6c09a7c01ffe7017976daf"},"url":"/posts$ $ons/2.27.0/node_modules/express/lib/application.js:230:10)"},"msg":"Site is starting up, please wait a moment then retry.","time":"2019-08-06T15:50:42.559Z","v":0}

Just realised that I did not paste the full message. But it does not seem to have logged relevant info there?

The blog is up and running, and sends emails with not problem. Itā€™s just image uploading issue. Weā€™ve checked folder permissions, it looks like user ghost has sufficient permissions. Also ghost doctor says everything is good! :thinking:

Many thanks!

All I can see so far is that two requests errored with a 502:

Part way through your stack trace I can see:

vendor.min-b2f8edd0972fea6d8bd360ed183797f6.js:10161 Uncaught TypeError: Cannot read property ā€˜urlā€™ of undefined

And in the error log I can see parts of errors:

ā€œcodeā€:ā€œIMAGE_SIZE_URLā€,

This is super weird, but itā€™s not enough information to debug the problem

Try looking in the non error ghost log, and look for reference to those 2 requests.

You can also try looking in /var/log/nginx/error.log.

1 Like

Nginx error log:

......
2019/08/06 19:25:07 [error] 5255#0: *2261264 open() "/opt/statics/public/wp-login.php" failed (2: No such file or directory), client: 197.62.xxx.xx, server: www.domain.com, request: "GET /wp-login.php HTTP/1.1", host: "www.domain.com"
2019/08/06 19:34:09 [error] 5255#0: *2261286 upstream prematurely closed connection while reading response header from upstream, client: 194.75.xxx.xxx, server: www.domain.com, request: "POST /blog/ghost/api/v2/admin/images/upload/ HTTP/2.0", upstream: "http://46.101.xx.xx:2368/blog/ghost/api/v2/admin/images/upload/", host: "www.domain.com", referrer: "https://www.domain.com/blog/ghost/"

So weā€™re hosing Ghost on a separate droplet (and as a subdirectory). This error log is from the main siteā€™s nginx.

was debugging with ghost run instead of ghost start and it just workedā€¦ so weird!! now switching back to ghost start and seeā€¦

and now the issue is backā€¦ :man_facepalming:

1 Like

I have the same issue here!

1 Like

I have the exact same issue. I just updated to 2.31.1. I canā€™t upload images without a 502 error. When I debug in ghost run it works perfectly. Then I go to ghost start and it 502ā€™s again.

Whenever I try to upload an image it gives me an error and the blog restarts on the server side.

Update: I rolled back my version to 2.30.2 and it started working again.

Hmmm ok - is anyone able to find anything relevant in the Ghost log? Logs are kept in /content/logs.

@Juan_Carlos_Orrego are you also on a subdirectory?

FYI - I tried updating to the latest version again and now Iā€™m getting a specific error from ghost run. Iā€™ve posted the output here: 502 on image upload, but works fine with `ghost run` Ā· Issue #11129 Ā· TryGhost/Ghost Ā· GitHub. I rolled back to 2.30.2 and it works fine.

Nevermind, v.2.34.0 fixed my 500 error issue. However, now my 502 error on image upload (not occuring during ghost run ) is back :frowning:

I am getting the same error. I am running 2.34.0 and the error is returning with a 502.

@ekerstein This is really weird. Can you double check ghost doctor for me, and also take a look at your current/node_modules folder and see if sharp is in there?

@bencstrs is this only on image upload? If not can you please start a new thread with full details and logs?

P.S. @ekerstein Iā€™ve reopened 502 on image upload, but works fine with `ghost run` Ā· Issue #11129 Ā· TryGhost/Ghost Ā· GitHub

Hi Hannah,

Yep it is only on image upload.