4

I'm trying to install HHVM on Debian 7 by prebuilt package. I've another server with the same configuration and it's working but in one of the servers HHVM FastCGI refuses the connection

It's /var/log/nginx/error.log

2014/11/25 23:24:10 [error] 422#0: *39 connect() failed (111: Connection refused) while connecting to upstream, client: 213.128.95.22, server: , request: "GET /api/v2/checkaccess HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "77.75.35.140"

I'm sure that HHVM daemon is working and listening 9000. port.

COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
hhvm    12192 www-data   16u  IPv6 792971      0t0  TCP *:9000 (LISTEN)

But also I cannot connect with telnet

root@server:/home/itusozlukcom# telnet 127.0.0.1 9000
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

I'm sure that there's no problem with the code because the same code works in another server and in this server the code works by HHVM CLI.

HHVM error.log is empty.

What can be the problem?

Cagatay Gurturk
  • 7,186
  • 3
  • 34
  • 44
  • both nginx and hhvm daemons are in local, so i don't think that it's about the firewall – Cagatay Gurturk Nov 25 '14 at 21:59
  • I can telnet to localhost but not 127.0.0.1, maybe you're right but i changed hhvm.conf and i've put localhost instead of 127.0.0.1, the problem persists. – Cagatay Gurturk Nov 25 '14 at 22:04
  • 2014/11/26 00:04:50 [error] 16354#0: *18 no live upstreams while connecting to upstream, client: 213.128.95.22, server: , request: "GET /api/v2/checkaccess HTTP/1.1", upstream: "fastcgi://localhost", host: "77.75.35.140" – Cagatay Gurturk Nov 25 '14 at 22:05
  • Just to make sure, in your last comment the upstream spells "fastcgi://localhost", shouldn't that be "fastcgi://localhost:9000"? – snout1979 Jan 06 '15 at 01:27

2 Answers2

6

I just realized the problem by myself.

HHVM with its default setting without specifying the IP to listen, was only listening ipv6 addresses. Because of that i could connect with localhost but not with 127.0.0.1

Specifying the IP by hhvm.server.ip = 127.0.0.1 solved the problem.

Cagatay Gurturk
  • 7,186
  • 3
  • 34
  • 44
  • I gave it a try too. But for me the error stil exists. `connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.99.1, server: localhost, request: "GET /index.hh HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.99.100"` This is from the error.log inside the hhvm container. So nginx is talking to hhvm but hhvm do not want to talk... I printed `phpinfo()` and it tells me `hhvm.server.ip 127.0.0.1` This worked after creating the `/etc/hhvm/php.ini` Do you have any clues? – bdart Oct 08 '15 at 14:57
4

As you are running both Nginx and HHVM on the same server, it is best practice (for added performance) to connect to a Unix socket instead.

To allow socket connections, change /etc/hhvm/server.ini

;hhvm.server.port = 9000    
hhvm.server.file_socket=/var/run/hhvm/hhvm.sock

I commented out the server port, as you probably don't want HHVM to listen to that port anymore.

In your Nginx configuration make fastcgi_pass use the socket you defined

fastcgi_pass unix:/var/run/hhvm/hhvm.sock;

Restart both Nginx and HHVM, optionally check if /var/run/hhvm/hhvm.sock actually exists and give it a go!

snout1979
  • 594
  • 2
  • 8
  • Thanks but it's not the answer of this question. I've been using unix sockets but under high load i get some 502 gateway errors that i think that because of socket's limits. So i want to make work the tcp way and try under heavy load. – Cagatay Gurturk Jan 01 '15 at 19:29
  • I'm not sure if the extra overhead/performance drop of TCP/IP vs Unix Sockets is going to solve your issue. I would first look into kernel settings you might want to tweak for higher load, particularly raising fs.file-max and increasing the buffer size of the socket backlog, together with increasing the amount of allowed 'backlog sockets' Some excellent tips can be found at http://tweaked.io/guide/kernel/ – snout1979 Jan 01 '15 at 20:10