Results 1 to 4 of 4

Thread: PostgreSQL on Leap 42.2: Connection Rejected

  1. #1

    Default PostgreSQL on Leap 42.2: Connection Rejected

    I'm having a problem running PostgreSQL on Leap 42.2. The problem is that once the number of connections rises over 500 (yes, I need that), new Connections are refused. I've been running on OpenSUSE 13.2 without any problem. I have already adjusted the Max Connections property in ~postgres/data/postgresql.conf. The error message I see is:

    Connection rejected: could not fork new process for connection: Resource temporarily unavailable.

    I tried adjusting /etc/security/limits.conf

    # harden against fork-bombs 
    postgres    -    nproc        unlimited
    postgres    -    nofile        65536
    postgres    -    memlock        unlimited
    *               hard    nproc           1700
    *               soft    nproc           1200
    root            hard    nproc           3000
    root            soft    nproc           1850
    # End of file
    The output of /proc/[pid]/limits is:

    Limit                     Soft Limit           Hard Limit           Units     
    Max cpu time              unlimited            unlimited            seconds   
    Max file size             unlimited            unlimited            bytes     
    Max data size             unlimited            unlimited            bytes     
    Max stack size            8388608              unlimited            bytes     
    Max core file size        0                    unlimited            bytes     
    Max resident set          unlimited            unlimited            bytes     
    Max processes             386643               386643               processes 
    Max open files            1024                 4096                 files     
    Max locked memory         65536                65536                bytes     
    Max address space         unlimited            unlimited            bytes     
    Max file locks            unlimited            unlimited            locks     
    Max pending signals       386643               386643               signals   
    Max msgqueue size         819200               819200               bytes     
    Max nice priority         0                    0                    
    Max realtime priority     0                    0                    
    Max realtime timeout      unlimited            unlimited            us
    Finally, when I su to postgres ulimit -a reports:
    core file size          (blocks, -c) 0
    data seg size           (kbytes, -d) unlimited
    scheduling priority             (-e) 0
    file size               (blocks, -f) unlimited
    pending signals                 (-i) 386643
    max locked memory       (kbytes, -l) unlimited
    max memory size         (kbytes, -m) unlimited
    open files                      (-n) 65536
    pipe size            (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority              (-r) 0
    stack size              (kbytes, -s) 8192
    cpu time               (seconds, -t) unlimited
    max user processes              (-u) unlimited
    virtual memory          (kbytes, -v) unlimited
    file locks                      (-x) unlimited
    If someone could help me understand what I need to do to get around this security feature, I would really appreciate it.

  2. #2
    Join Date
    Jun 2008
    San Diego, Ca, USA
    Blog Entries

    Default Re: PostgreSQL on Leap 42.2: Connection Rejected

    Have you shifted more resources to your network sockets?

    The following link is to part of a longer article I wrote many years ago, but AFAIK should still be completely applicable today

    I haven't checked recently to know if the default values described in what I wrote have not changed and would not be surprised if still the same. If you have other issues, then other settings related to optimizing resources and configuration for various types of network connections are also described... for example if your network connections are faster than wired 100bit (fast) ethernet (today that's almost guaranteed).

    Beginner Wiki Quickstart -
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  3. #3
    Join Date
    Oct 2011
    Germany (Ore Mountains)

    Default Re: PostgreSQL on Leap 42.2: Connection Rejected

    systemd (logind) is also limiting user processes ("tasks").


    And btw. with so many connections you should start to consider connection pooling.


  4. #4

    Default Re: PostgreSQL on Leap 42.2: Connection Rejected

    As others pointed out, the issue is SystemD. See this discussion:

    I edited postgresql.service and put


    in the Service section. Things now work as expected.

    This is quite a problem. There are max connections in postgresql.conf, TasksMax in systemd, and all of the knobs in /etc/security/limits.conf.

    It would be nice to edit postgersql.service and set a default TasksMax to infinity by default.


    I am using Connection Pooling, but I'm running a SaS cloud server with about 1250 instance of my application deployed. Even with pooling, it's a lot of Connections. My connection pool is also designed to close down quiescent connections after 3 minutes.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts