Next.js Discord

Discord Forum

full stack Next app on vercel

Unanswered
Miniature American Shepherd posted this in #help-forum
Open in Discord
Miniature American ShepherdOP
please someone help i dont know how to do that i am geting 404 error when i am uploading but dont have errors in logs why?

118 Replies

Miniature American ShepherdOP
i have api routes in my pages directory and using mysql as a database
@Miniature American Shepherd still need more info
what is returning a 404
can I see the code for the page returning a 404
and the route
Miniature American ShepherdOP
Yes I deployed it now I don't get 404 but
Requests doesnot work
I can't help if that's all the info you have
Miniature American ShepherdOP
I am using mysql
Can be that is a problem?
no
well maybe
can you send code and give me more details
Miniature American ShepherdOP
Him request says that it cant see host
You know mysql has host
My host is ioturman
Yes wait
const dbConfig = {
    host: process.env.DB_HOST || 'ioturman',
    port: process.env.DB_PORT || 3306,
    user: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
};
this is my database file code
when i make a request i get 500 internalserver error
and in preview i get this error
thanks in advance
in vercel build blogs there is no errors at all
DB_HOST=ioturman   
DB_PORT=3306   
DB_USER=ioane_tech
DB_PASSWORD=*******
this is my env file
I still don't know enough to help, sorry
maybe someone else will be able to
@Miniature American Shepherd DB_HOST=ioturman DB_PORT=3306 DB_USER=ioane_tech DB_PASSWORD=*******
Vespid wasp
Can you login with this credentials directly with heidi, dbeaver, or else tool?...
@Lukas I still don't know enough to help, sorry
Miniature American ShepherdOP
What do you want to know exactly
Vespid wasp
DB_HOST=https://192.168.0.1
or with domain
DB_HOST=https://mydatabase.com.br
Miniature American ShepherdOP
I have mysql localy
@Miniature American Shepherd I have mysql localy
Vespid wasp
then localhost
Miniature American ShepherdOP
And want to upload it on vercel
@Miniature American Shepherd And want to upload it on vercel
Vespid wasp
Where is your database hosted?
Miniature American ShepherdOP
I have full stack next app
My database is not hosted
I didnot do anything like that
Vespid wasp
And can you host your database in the same NEXT application?
I knew the backend is possible, but the database didn't know
Miniature American ShepherdOP
I don't get what you are saying
Thanks for helping
So I need to host my db somewhere?
@Miniature American Shepherd I don't get what you are saying
Vespid wasp
Locally work fine?
Miniature American ShepherdOP
Yes localy work fine
Everything is cool
Vespid wasp
Where is your database?
Miniature American ShepherdOP
I downloaded mysql
And there is my database
In my instance
Vespid wasp
So your database is on your PC separate from your project
Miniature American ShepherdOP
Yes
Vespid wasp
With your project published, you will have to pass your IP to their database
Miniature American ShepherdOP
But I am creating databases from my frontend
And making changes on that databases add tables and so on
@Vespid wasp *With your project published, you will have to pass your IP to their database*
Miniature American ShepherdOP
What do you mean exactly
Vespid wasp
So, in DB_HOST it must be your PC's IP
Miniature American ShepherdOP
Okay
And it will work fine?
@Miniature American Shepherd And it will work fine?
Vespid wasp
Yes, if you have released and redirected the ports on your router correctly
Miniature American ShepherdOP
So if my PC is shut down
Website will not work?
@Miniature American Shepherd So if my PC is shut down
Vespid wasp
DB wont work
Miniature American ShepherdOP
Aha okay
Thanks a lot I will try
@Miniature American Shepherd Website will not work?
Vespid wasp
If you need to query your database, it won't work.
Miniature American ShepherdOP
Ye understand
I have a question
Byt why it work fine on localhost when I run my project localy
@Miniature American Shepherd Byt why it work fine on localhost when I run my project localy
Vespid wasp
Why should your ioturman be pointing to localhost. So when you are on your PC, it will work correctly
@Vespid wasp *Yes, if you have released and redirected the ports on your router correctly*
Miniature American ShepherdOP
What do you mean in this?
Vespid wasp
But, when you publish your project. The next server doesn't know what IOTURMAN is.
Miniature American ShepherdOP
Okay understand
Thanks
@Miniature American Shepherd What do you mean in this?
Vespid wasp
Look at the model of your router, and then enter its name with Port forwarding, there will be a video explaining how to do it. It will be better explained
But basically, you will have to release and point port 3306, to the IP of your computer within the network, which will be something like 192.168 I think...
Miniature American ShepherdOP
Okay thanks what to write to see that video
How to search
Aha thanks a lot bro
Vespid wasp
And then you will be able to connect to your database hosted on your computer through the published project
And here you can see your public IP, which will be the one you will use in your published project
Miniature American ShepherdOP
Thank you
Vespid wasp
Miniature American ShepherdOP
Okay so I should not use 192.12.12.22 something like that?
@Miniature American Shepherd Okay so I should not use 192.12.12.22 something like that?
Vespid wasp
This is on your router, because this is your IP within your local network
@Vespid wasp https://whatismyip.com.br/
Vespid wasp
But your IP seen from outside your home will be this
Miniature American ShepherdOP
Okay
Vespid wasp
For example, if you are hosting the mysql database. And I want to connect from my home, I will use your IP as stated on this website
Miniature American ShepherdOP
So I should write my ipod in the internet and ask what will be my public ip
But ip address changes over time isnt it a problem?
@Miniature American Shepherd But ip address changes over time isnt it a problem?
Vespid wasp
This, you will have to pay attention and update
Miniature American ShepherdOP
Okay
Vespid wasp
Or, you can ask your internet provider, but fixed IP is usually expensive
Miniature American ShepherdOP
Okay
Thanks a lot
Good luck
Miniature American ShepherdOP
@Vespid wasp when i am making request

"connect ETIMEDOUT"
i have this error
know why?
Miniature American ShepherdOP
i went through all this steps but i have same error

Check Hostname/IP:

Ensure the DB_HOST in your .env file is your public IP (if your database is accessible publicly) or a domain name that resolves to the correct IP.
Allow External Connections:

If your MySQL server is on your local machine, make sure it's configured to accept external connections. You can do this by editing the my.cnf or my.ini file and ensuring that the bind-address is set to 0.0.0.0 or your specific IP.
Additionally, you need to ensure that your router is set to forward the MySQL port (3306) to your local machine.
Firewall Rules:

Check your firewall settings to ensure that the MySQL port (3306) is open for connections from Vercel's IP ranges. You may need to whitelist specific IP ranges.
Use a Remote Database:

If your database is running on your local machine and you experience connectivity issues, consider using a cloud-based MySQL service (like AWS RDS, Google Cloud SQL, etc.) that is designed for remote access.
Increase Connection Timeout:

You might want to increase the connection timeout in your MySQL client configuration. This won’t fix underlying connection issues but could give you more time for the connection to establish.
this steps are provided by chat gpt
@Miniature American Shepherd <@287427589482610689> when i am making request "connect ETIMEDOUT"
Vespid wasp
this is telling you, the connection time out. This mean, you app trying connect to database but attempts to connection expired
I think your IP is not accessible
Miniature American ShepherdOP
Hm okay will check it thanks
Gn
Vespid wasp
Open cmd on your pc, and run ipconig
You will have the IP referring to the Wi-Fi connection and the IP referring to the ethernet connection. Write down the ip of the device you are using
You will have the IP referring to the Wi-Fi connection and the IP referring to the ethernet connection. Write down the ip of the device you are using
We will save the info

IP LOCAL: 
With your local IP noted. You should access your router settings. Usually typing in the browser 192.168.0.1 you access it, if it is not, below it has the instructions
Being in your router settings, you should look for port forwarding. And then put port 3306 to your LOCAL IP.
Why is that? Why when I enter your PUBLIC IP WITH PORT 3306. The router will forward to your computer, not to your mobile phone, notebook, or any other device connected to your route
@Vespid wasp https://whatismyip.com.br/
Vespid wasp
Your public IP can get here
@Vespid wasp *Open cmd on your pc, and run ipconig*
Vespid wasp
ipconfig
Miniature American ShepherdOP
thanks a lot