Error: Request Entity Too Large



  • I get this error if I want to upload a big (in filesize) picture.

    0_1537376053690_9de3fc69-6b5d-4400-b5bd-9db80bc222d9-image.png

    I found this

    but I don't understand what I must do. Can somebody help me?


  • Staff Admin

    Do you use nginx? If so add this client_max_body_size 5M; in to you nodebb nginx config file under location /
    For example

    server {
        listen 80;
    
        server_name forum.example.org;
    
        location / {
            client_max_body_size 5M;
    
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
    
            proxy_pass http://127.0.0.1:4567;
            proxy_redirect off;
    
            # Socket.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }
    

    Also make sure the allowed file size is 5megabytes in NodeBB ACP as well.



  • @baris yes i use nginx but my nginx looks like this.

    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;
    include /etc/nginx/modules-enabled/*.conf;
    
    events {
    	worker_connections 768;
    	# multi_accept on;
    }
    
    http {
    
    	##
    	# Basic Settings
    	##
    
    	sendfile on;
    	tcp_nopush on;
    	tcp_nodelay on;
    	keepalive_timeout 65;
    	types_hash_max_size 2048;
    	# server_tokens off;
    
    	# server_names_hash_bucket_size 64;
    	# server_name_in_redirect off;
    
    	include /etc/nginx/mime.types;
    	default_type application/octet-stream;
    
    	##
    	# SSL Settings
    	##
    

    Is the file /etc/nginx/nginx.conf


  • Staff Admin

    Check the folder /etc/nginx/sites-available/



  • @baris said in Error: Request Entity Too Large:

    Check the folder /etc/nginx/sites-available/

    yes, here is a file with a filename the same as my domain. The file has the information as your post here.

    Thanks I go edit it.



  • edited the file. If I go to my site I get this.

    0_1537386923415_873173ea-f175-4ed8-b236-4570337b8933-image.png



  • ./nodebb log gives:

    
        at emitOne (events.js:116:13)
        at Pool.emit (events.js:211:7)
        at Connection.<anonymous> (/root/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:329:12)
        at Object.onceWrapper (events.js:317:30)
        at emitTwo (events.js:126:13)
        at Connection.emit (events.js:214:7)
        at Socket.<anonymous> (/root/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:245:50)
        at Object.onceWrapper (events.js:315:30)
        at emitOne (events.js:116:13)
    [cluster] Child Process (1136) has exited (code: 0, signal: null)
    
    


  • ./nodebb dev gives

    NodeBB v1.10.1 Copyright (C) 2013-2014 NodeBB Inc.
    This program comes with ABSOLUTELY NO WARRANTY.
    This is free software, and you are welcome to redistribute it under certain conditions.
    For the full license, please visit: http://www.gnu.org/copyleft/gpl.html
    
    Clustering enabled: Spinning up 1 process(es).
    
    2018-09-19T20:01:58.845Z [1171] - info: Initializing NodeBB v1.10.1 http://pubers.wtf:4567
    2018-09-19T20:01:58.849Z [1171] - verbose: * using mongo store at 127.0.0.1:27017
    2018-09-19T20:01:58.850Z [1171] - verbose: * using themes stored in: /root/nodebb/node_modules
    2018-09-19T20:01:59.037Z [1171] - error: NodeBB could not connect to your Mongo database. Mongo returned the following error message=failed to connect to server [127.0.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017], name=MongoNetworkError, stack=MongoNetworkError: failed to connect to server [127.0.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
        at Pool.<anonymous> (/root/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:505:11)
        at emitOne (events.js:116:13)
        at Pool.emit (events.js:211:7)
        at Connection.<anonymous> (/root/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:329:12)
        at Object.onceWrapper (events.js:317:30)
        at emitTwo (events.js:126:13)
        at Connection.emit (events.js:214:7)
        at Socket.<anonymous> (/root/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:245:50)
        at Object.onceWrapper (events.js:315:30)
        at emitOne (events.js:116:13)
    2018-09-19T20:01:59.040Z [1171] - error:  message=failed to connect to server [127.0.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017], name=MongoNetworkError, stack=MongoNetworkError: failed to connect to server [127.0.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
        at Pool.<anonymous> (/root/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:505:11)
        at emitOne (events.js:116:13)
        at Pool.emit (events.js:211:7)
        at Connection.<anonymous> (/root/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:329:12)
        at Object.onceWrapper (events.js:317:30)
        at emitTwo (events.js:126:13)
        at Connection.emit (events.js:214:7)
        at Socket.<anonymous> (/root/nodebb/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:245:50)
        at Object.onceWrapper (events.js:315:30)
        at emitOne (events.js:116:13)
    [cluster] Child Process (1171) has exited (code: 0, signal: null)
    
    

  • Staff Admin

    Looks like your Mongodb database isn't running or is inaccessible.


  • Staff Admin

    You can test changes to your nginx config by nginx -t to make sure there are no errors.



  • @baris said in Error: Request Entity Too Large:

    You can test changes to your nginx config by nginx -t to make sure there are no errors.

    nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    


  • @baris said in Error: Request Entity Too Large:

    Looks like your Mongodb database isn't running or is inaccessible.

    how can I fix this?
    How can I check errors?
    Can you please help me?


  • Staff Admin

    You need to restart mongodb, https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/#restart-mongodb, to check for mongodb errors you can look at the file in /var/log/mongodb/mongod.log



  • @baris said in Error: Request Entity Too Large:

    /var/log/mongodb/mongod.log

    Is it safe to post this information in this file?



  • @baris said in Error: Request Entity Too Large:

    You need to restart mongodb, https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/#restart-mongodb, to check for mongodb errors you can look at the file in /var/log/mongodb/mongod.log

    Sir you're my hero 😄

    sudo service mongod start worked for me, the site is back 🙂

    Thanks a lot for your quick reply and your help 🙂


  • Staff Admin

    Is it safe to post this information in this file?

    I don't think that file contains any sensitive info, but you can double check before posting.

    Glad the site is back. If mongodb was down due to lack of memory you might have to upgrade your server or it might happen again.



  • @baris said in Error: Request Entity Too Large:

    Is it safe to post this information in this file?

    I don't think that file contains any sensitive info, but you can double check before posting.

    Glad the site is back. If mongodb was down due to lack of memory you might have to upgrade your server or it might happen again.

    I have digitalocean and I did poweroff command so I could take snapshot.

    Maybe mongodb shuts down if I use power off, of doesn't it?



  • btw the problem with the filesize is also solved 🙂


Log in to reply
 

Suggested Topics

  • 1
  • 2
  • 8
  • 7
  • 26
| |