Results 1 to 18 of 18
  1. #1

    NginX upstream timed out (110: Connection timed out) while connecting to upstream

    Hello,

    I keep on getting problems with my NginX setup using php-fpm, all latest versions.
    It's many like these:
    2011/01/06 19:50:00 [error] 4660#0: *10702343 upstream timed out (110: Connection timed out) while connecting to upstream, client: xx.xx.xx.xx, server: xxx.yyy, request: "GET / HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "xxx.yyy"

    These errors only occur while there are many requests, like over 1,000/s.

    [root@db ~]# uname -a
    Linux db.2.6.18-194.26.1.el5 #1 SMP Tue Nov 9 12:54:20 EST 2010 x86_64 x86_64 x86_64 GNU/Linux
    [root@db ~]# 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) 210944
    max locked memory (kbytes, -l) 32
    max memory size (kbytes, -m) unlimited
    open files (-n) 50000
    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) 210944
    virtual memory (kbytes, -v) unlimited
    file locks (-x) unlimited


    request_terminate_timeout = 60 is already set in php-fpm.conf .
    I searched the whole Internet for this problem and couldn't find anything to help me out.
    Thank you!

  2. #2
    Join Date
    Mar 2009
    Location
    Gods Own Country
    Posts
    681
    Try increasing the worker thread ( max_children )
    Fabin Mundattil @ Xieles Support
    High Quality Server Management | support @ xieles.com
    https://xieles.com

  3. #3
    Join Date
    Mar 2003
    Location
    California USA
    Posts
    13,681
    You need more php workers, not nginx workers.
    Steven Ciaburri | Industry's Best Server Management - Rack911.com
    Software Auditing - 400+ Vulnerabilities Found - Quote @ https://www.RACK911Labs.com
    Fully Managed Dedicated Servers (Las Vegas, New York City, & Amsterdam) (AS62710)
    FreeBSD & Linux Server Management, Security Auditing, Server Optimization, PCI Compliance

  4. #4
    That still didn't work.
    These are my php-fpm settings:

    pm.max_children = 20000
    pm.start_servers = 40
    pm.min_spare_servers = 20
    pm.max_requests = 0
    pm.max_spare_servers = 40

    Thanks

  5. #5
    Join Date
    Mar 2003
    Location
    California USA
    Posts
    13,681
    You could be hitting other limits in your fastcgi implementation - file descriptor limits on the php user (you only showed us root limit) etc.

    Regardless of the cause, the problem is with php. Check/Enable logging for your php fastcgi installation.
    Steven Ciaburri | Industry's Best Server Management - Rack911.com
    Software Auditing - 400+ Vulnerabilities Found - Quote @ https://www.RACK911Labs.com
    Fully Managed Dedicated Servers (Las Vegas, New York City, & Amsterdam) (AS62710)
    FreeBSD & Linux Server Management, Security Auditing, Server Optimization, PCI Compliance

  6. #6
    Join Date
    Jun 2001
    Location
    Denver, CO
    Posts
    3,302
    Why are you running PHP on your nginix host? Use nginix to reverse proxy to a couple of backend servers. Spread the love.
    Jay Sudowski // Handy Networks LLC // Co-Founder & CTO
    AS30475 - Level(3), HE, Telia, XO and Cogent. Noction optimized network.
    Offering Dedicated Server and Colocation Hosting from our SSAE 16 SOC 2, Type 2 Certified Data Center.
    Current specials here. Check them out.

  7. #7
    Quote Originally Posted by Steven View Post
    You could be hitting other limits in your fastcgi implementation - file descriptor limits on the php user (you only showed us root limit) etc.

    Regardless of the cause, the problem is with php. Check/Enable logging for your php fastcgi installation.
    It's not that
    [root@db ~]# 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) 210944
    max locked memory (kbytes, -l) 32
    max memory size (kbytes, -m) unlimited
    open files (-n) 10000
    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) 210944
    virtual memory (kbytes, -v) unlimited
    file locks (-x) unlimited


    daemon soft nofile 90000
    daemon hard nofile 90000

    Thanks

  8. #8
    Join Date
    Nov 2006
    Posts
    939
    Also, when using php-fpm with nginx, I've found it better to use a unix socket instead of tcp/ip if it's all on the same box.

  9. #9
    Quote Originally Posted by nickakam View Post
    Also, when using php-fpm with nginx, I've found it better to use a unix socket instead of tcp/ip if it's all on the same box.
    That would fix the problem most likely, how did you do it?

  10. #10
    Join Date
    Nov 2006
    Posts
    939
    Taken from a live conf file:

    In nginx.conf:

    location ~ \.php$ {
    fastcgi_pass unix:/tmp/php.sock;
    etc etc etc
    }

    In php-fpm.conf:

    ;listen = 127.0.0.1:9000
    listen = /tmp/php.sock

    Just change from an IP address to a unix socket address basically, simples. Not sure it'd fix your problem though. Are you on 5.3.4?
    Last edited by EasyInternet_Nick; 01-07-2011 at 12:10 PM.

  11. #11
    Join Date
    Mar 2003
    Location
    California USA
    Posts
    13,681
    Quote Originally Posted by GarS View Post
    It's not that
    [root@db ~]# 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) 210944
    max locked memory (kbytes, -l) 32
    max memory size (kbytes, -m) unlimited
    open files (-n) 10000
    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) 210944
    virtual memory (kbytes, -v) unlimited
    file locks (-x) unlimited


    daemon soft nofile 90000
    daemon hard nofile 90000

    Thanks
    Thats still the root limit. Are you running php as root?
    Steven Ciaburri | Industry's Best Server Management - Rack911.com
    Software Auditing - 400+ Vulnerabilities Found - Quote @ https://www.RACK911Labs.com
    Fully Managed Dedicated Servers (Las Vegas, New York City, & Amsterdam) (AS62710)
    FreeBSD & Linux Server Management, Security Auditing, Server Optimization, PCI Compliance

  12. #12
    Join Date
    Jun 2005
    Posts
    2,752
    Quote Originally Posted by Jay Suds View Post
    Why are you running PHP on your nginix host? Use nginix to reverse proxy to a couple of backend servers. Spread the love.
    OFF-TOPIC

    What is your opinion about running Varnish instead Nginx as reverse proxy to backend servers? Thanks.
    You will only find out how good a provider is when the going gets tough

  13. #13
    Quote Originally Posted by Steven View Post
    Thats still the root limit. Are you running php as root?
    No, I am running it under a default user "daemon".
    I've added session required pam_limits.so to /etc/pam.d/login and also set
    daemon soft nofile unlimited
    daemon hard nofile unlimited
    daemon soft nproc unlimited
    daemon hard nproc unlimited

    in /etc/security/limits.conf
    I still get the error "upstream timed out (110: Connection timed out) while connecting to upstream, client"

  14. #14
    Quote Originally Posted by Jay Suds View Post
    Why are you running PHP on your nginix host? Use nginix to reverse proxy to a couple of backend servers. Spread the love.
    I can't see the point in making a separation between the nginx and php-fpm. I would just do useless network traffic.

  15. #15
    Quote Originally Posted by dotHostel View Post
    OFF-TOPIC

    What is your opinion about running Varnish instead Nginx as reverse proxy to backend servers? Thanks.
    I am not sure how would that work for me and what other advantages would it bring. I am already using memcache an round robin nginx+php-fpm servers.
    Thanks

  16. #16
    Join Date
    Jun 2005
    Posts
    2,752
    Quote Originally Posted by GarS View Post
    I can't see the point in making a separation between the nginx and php-fpm. I would just do useless network traffic.
    It makes a lot of sense but not all sites need multitiered configuration. I was not suggesting you to use as I don't know what is your application, server load, traffic, visitor geographic distribution, etc -- just asking Jay Suds an opinion regarding two specific software (ngnix vs varnish) between many others used to do reverse proxy.
    Last edited by dotHostel; 01-08-2011 at 07:19 AM.
    You will only find out how good a provider is when the going gets tough

  17. #17
    why does my php-fpm.conf be written with XML style. The INI format broken the server starting up. help~

  18. #18
    I have the same problem, did you find any solution to this?

Similar Threads

  1. nginx upstream timed out error
    By heropage in forum Hosting Security and Technology
    Replies: 14
    Last Post: 11-30-2012, 06:39 PM
  2. Connection Timed Out
    By mamasfinds in forum Web Hosting
    Replies: 5
    Last Post: 01-27-2008, 01:57 PM
  3. The connection has timed out - Please Help
    By computerness in forum Hosting Security and Technology
    Replies: 7
    Last Post: 01-24-2008, 11:59 PM
  4. The connection has timed out
    By zodehala in forum Hosting Security and Technology
    Replies: 2
    Last Post: 12-25-2007, 09:26 PM
  5. 425 Unable to build data connection: Connection timed out
    By vnunited in forum Hosting Security and Technology
    Replies: 3
    Last Post: 05-15-2006, 12:42 PM

Posting Permissions

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