Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad Gateway app login - serious issue #532

Closed
mohdlatif opened this issue Jul 29, 2020 · 12 comments
Closed

Bad Gateway app login - serious issue #532

mohdlatif opened this issue Jul 29, 2020 · 12 comments

Comments

@mohdlatif
Copy link

Hi there, I have spent countless hours trying to configure nginxproxymanager on my server.
My server details:
OS: Centos 7
Nginx
Docker and docker compose latest version.
I am using https://vpssim.com/.

I created a subdomain and in the public_html folder I created both files config.json and docker-compose.yml

The first issue i faced is port 443 is used to generate certificate and 80 is being used by Nginx, so i have to find a way to change the ports.

So I did a little configuration by changing the port like this

  **- '8080:80'
  - '81:81'
  - '8443:443'**

Great, it works and the port 3306 is running
image

The issue after this is whenever i try to login it says Bad Gateway

image

I have read many threads about this issue,

Here is what I have done

Change "host": "db" to "host": "my server IP", - Does not work
Change "host": "db" to "host": "subdomain.mywebsite.com", - Does not work
Turned off Nginx via systemctl stop nginx.service and run on the defaults ports (port 443 and 80)- Does not work

Here is log file

2020/07/29 11:21:24 [error] 245#245: *1973 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:30 [error] 245#245: *1975 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:35 [error] 245#245: *1977 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:40 [error] 245#245: *1979 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:45 [error] 245#245: *1981 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:49 [error] 245#245: *1984 connect() failed (111: Connection refused) while connecting to upstream, client: 202.186.36.196, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "nprxy.mywebsite.com:81", referrer: "http://nprxy.mywebsite.com:81/" 2020/07/29 11:21:51 [error] 245#245: *1986 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:56 [error] 245#245: *1988 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:59 [error] 245#245: *1984 connect() failed (111: Connection refused) while connecting to upstream, client: 202.186.36.196, server: nginxproxymanager, request: "POST /api/tokens HTTP/1.1", upstream: "http://127.0.0.1:3000/tokens", host: "nprxy.mywebsite.com:81", referrer: "http://nprxy.mywebsite.com:81/login" 2020/07/29 11:22:01 [error] 245#245: *1991 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81"

How i can solve this issue.

Thanks.

@godsom
Copy link

godsom commented Aug 21, 2020

I got same issue after first run docker-compose from full guide.
from from my point database cannot start
I fixed by change docker-compose.yml from
db:
image: jc21/mariadb-aria:10.4
to
db:
image: mariadb:latest

@iga566
Copy link

iga566 commented Sep 14, 2020

Hi there, I have spent countless hours trying to configure nginxproxymanager on my server.
My server details:
OS: Centos 7
Nginx
Docker and docker compose latest version.
I am using https://vpssim.com/.

I created a subdomain and in the public_html folder I created both files config.json and docker-compose.yml

The first issue i faced is port 443 is used to generate certificate and 80 is being used by Nginx, so i have to find a way to change the ports.

So I did a little configuration by changing the port like this

  **- '8080:80'
  - '81:81'
  - '8443:443'**

Great, it works and the port 3306 is running
image

The issue after this is whenever i try to login it says Bad Gateway

image

I have read many threads about this issue,

Here is what I have done

Change "host": "db" to "host": "my server IP", - Does not work
Change "host": "db" to "host": "subdomain.mywebsite.com", - Does not work
Turned off Nginx via systemctl stop nginx.service and run on the defaults ports (port 443 and 80)- Does not work

Here is log file

2020/07/29 11:21:24 [error] 245#245: *1973 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:30 [error] 245#245: *1975 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:35 [error] 245#245: *1977 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:40 [error] 245#245: *1979 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:45 [error] 245#245: *1981 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:49 [error] 245#245: *1984 connect() failed (111: Connection refused) while connecting to upstream, client: 202.186.36.196, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "nprxy.mywebsite.com:81", referrer: "http://nprxy.mywebsite.com:81/" 2020/07/29 11:21:51 [error] 245#245: *1986 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:56 [error] 245#245: *1988 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81" 2020/07/29 11:21:59 [error] 245#245: *1984 connect() failed (111: Connection refused) while connecting to upstream, client: 202.186.36.196, server: nginxproxymanager, request: "POST /api/tokens HTTP/1.1", upstream: "http://127.0.0.1:3000/tokens", host: "nprxy.mywebsite.com:81", referrer: "http://nprxy.mywebsite.com:81/login" 2020/07/29 11:22:01 [error] 245#245: *1991 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81"

How i can solve this issue.

Thanks.

i have the same issue

@codeagencybe
Copy link

codeagencybe commented Sep 19, 2020

I got it working!

db_1 | 2020-09-19 12:31:16 0 [ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 0 pages than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!

All I did was delete the .ibdata1 file that shows 0kb
And then re-deploy the whole setup. Now it generates a new clean .ibdata file that is around 12Mb size

@pierow2k
Copy link

I fixed by change docker-compose.yml from
db:
image: jc21/mariadb-aria:10.4
to
db:
image: mariadb:latest

Fixed the issue for me as well. Many thanks @godsom !

@wimmme
Copy link

wimmme commented Dec 3, 2020

For me on a RPI 3 running Hypriot

db:
image: mariadb:latest

does not work, but this does:

db:
image: yobasystems/alpine-mariadb:armhf

@anselal
Copy link

anselal commented Jan 4, 2021

@wimmme did not work for me on my rpi2

@mcarter960
Copy link

This worked for me also...running on a pi4. Thank you wimmme

creating config.json
and
editing docker-compose.yml
db:
image: yobasystems/alpine-mariadb:armhf

@anselal
Copy link

anselal commented Jan 25, 2021

This works on my RPi2

version: "2"
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: always
    ports:
      # Public HTTP Port:
      - '80:80'
      # Public HTTPS Port:
      - '443:443'
      # Admin Web Port:
      - '81:81'
    environment:
      # These are the settings to access your db
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
      DISABLE_IPV6: 'true'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - db
  db:
    image: yobasystems/alpine-mariadb:latest
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
    volumes:
      - ./data/mysql:/var/lib/mysql

the trick besides changing the image for the DB is to use version: "2"

@cxdy
Copy link

cxdy commented Feb 17, 2021

I'm running on Ubuntu 20.04 inside a virtual machine.

Docker version 20.10.3
docker-compose version 1.28.2

2021/02/17 01:36:08 [error] 261#261: *33 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81"
2021/02/17 01:36:13 [error] 261#261: *35 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81"
2021/02/17 01:36:17 [error] 261#261: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 10.0.0.4, server: nginxproxymanager, request: "POST /api/tokens HTTP/1.1", upstream: "http://127.0.0.1:3000/tokens", host: "10.0.0.7:81", referrer: "http://10.0.0.7:81/login"
2021/02/17 01:36:18 [error] 261#261: *38 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81"
2021/02/17 01:36:24 [error] 261#261: *40 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: nginxproxymanager, request: "GET /api/ HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "127.0.0.1:81"

Here is my config:

version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    environment:
      DB_MYSQL_HOST: "localhost"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "nginx"
      DB_MYSQL_PASSWORD: ""
      DB_MYSQL_NAME: "nginx"
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
  db:
    image: 'mariadb:latest'
    environment:
      MYSQL_ROOT_PASSWORD: ''
      MYSQL_DATABASE: 'nginx'
      MYSQL_USER: 'nginx'
      MYSQL_PASSWORD: ''
    volumes:
      - ./data/mysql:/var/lib/mysql

Firewall:

Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
81                         ALLOW       Anywhere
80                         ALLOW       Anywhere
443                        ALLOW       Anywhere
3000                       ALLOW       Anywhere

download

Any ideas?

@jc21
Copy link
Member

jc21 commented Feb 17, 2021

First rule of docker debugging:

docker logs name_of_npm_container

@cxdy
Copy link

cxdy commented Feb 17, 2021

@jc21 I resolved it by changing my MYSQL IP in the docker-compose.yml to the IP of the docker container. All is well now, thanks!

@jc21
Copy link
Member

jc21 commented Feb 17, 2021

In your example you can also set the database host name to db since it's in the same docker-compose file

@jc21 jc21 closed this as completed Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants