MongoDB Error: Connection refused because too many open connections:819

Source: Internet
Author: User
Tags postgresql


Problem:



Found MongoDB can not connect, view MongoDB log, there are a large number of errors as follows:





819


When the number of MONGODB connections reaches 819, it cannot be added, so it cannot be connected.






Analytical Solutions:


1. Maxconns Limit



By default, in a Linux system, MongoDB has a maximum number of connections of 819.



You can modify the maximum number of connections for MongoDB and modify its configuration file mongod.conf:





maxConns=20000 # officially specified, mongodb maximum connection number setting, can not exceed 20,000


Restart the MongoDB service for the configuration to take effect.






2. Ulimit Limit



If the Maxconns, or the too many open connections error, may also be related to the ulimit limit of the system.



Linux system default file handle for each process limit open files to 1024, this value is generally too small, need to be adjusted.


View all current limit information of the system.
# ulimit -a
Core file size (blocks, -c) 0
Data seg size (kbytes, -d) unlimited
Scheduling priority (-e) 0
File size (blocks, -f) unlimited
Pending signals (-i) 7672
Max locked memory (kbytes, -l) 64
Max memory size (kbytes, -m) unlimited
Open files (-n) 1024
Pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
Real-time priority (-r) 0
Stack size (kbytes, -s) 10240
Cpu time (seconds, -t) unlimited
Max user processes (-u) 1024
Virtual memory (kbytes, -v) unlimited
File locks (-x) unlimited 


Use Ulimit-n to modify the open files restriction: (current session is in effect)





 
# ulimit -n 102400


Change system limits, modify/etc/security/limits.conf, add the following line: (permanent)





 
* soft nofile 102400 
* hard nofile 102400




MongoDB Error: Connection refused because too many open connections:819


Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.