Unable to register with firebase

I am trying to create a registration form using firebase and login, I have tried so many things, but this will not work. I keep getting this error when I click on the register button that calls the auth.createUserWithEmailAndPassword(email, pass) method.

A network error has occurred (for example, a timeout, a disconnected connection, or an unavailable host).

Below is part of my HTML

 <div class="col l7" id="signup"> <h4>Signup</h4> <div class="form card"> <br> <div class="switch"> <label> Student <input name="student_" id="student_" type="checkbox"> <span class="lever"></span> Staff </label> </div> <div class="container"> <input type="text" placeholder="Name" id="signup_fullname"> <!--student/staff--> <input type="text" placeholder="Matric Number/Staff no." id="signup_matric"> <input type="email" placeholder="Email" id="signup_email"> <div class="input-field col s12"> <select id="signup_dept"> <option value="" disabled selected>Select your department</option> <option value="ics">ICS</option> <option value="masscomm">Mass Comm.</option> <option value="lis">Library Science</option> <option value="tcs">Telecomm Science</option> <option value="csc">Computer Science</option> </select> </div> <div class="input-field col s12"> <select id="signup_level"> <option value="" disabled selected>Select your Level</option> <option value="100">100 Level</option> <option value="200">200 Level</option> <option value="300">300 Level</option> <option value="400">400 Level</option> <option value="500">500 Level</option> </select> </div> <div class="input-field col s12"> <select id="signup_religion"> <option value="" disabled selected>Select your religion</option> <option value="1">Islam</option> <option value="2">Christianity</option> </select> </div> <input type="password" placeholder="password" id="signup_password"> <!--<input type="password" placeholder="Confirm password" id="signup_confirm_password">--> <button class="btn-large second-color" id="btnSignUp">signup</button></a> </div> </div> <br> </div> 

and my js code

 readystatemode = false; (function () { var config = { apiKey: "<my API key>", authDomain: "<my auth domain>", databaseURL: "<my database url>", storageBucket: "<my storage bucket url>", }; firebase.initializeApp(config); // Get Elements var student_ = document.getElementById('student_'); // check whether is a student or staff; expect on or off var student__; if (student_.value == "on") { student__ = "student"; } else { student__ = "staff"; } var signup_fullname = document.getElementById('signup_fullname'); var signup_matric = document.getElementById('signup_matric'); var signup_email = document.getElementById('signup_email'); var signup_dept = document.getElementById('signup_dept'); var signup_level = document.getElementById('signup_level'); var signup_religion = document.getElementById('signup_religion'); var signup_password = document.getElementById('signup_password'); var login_email = document.getElementById('login_email'); var login_password = document.getElementById('login_password'); // buttons var btnLogin = document.getElementById("btnLogin"); var btnSignUp = document.getElementById("btnSignUp"); // signup event btnSignUp.addEventListener('click', e => { // Get Email and pass //TODO: check for real emails console.log("just clicked the signup button"); var email = signup_email.value; var pass = signup_password.value; var auth = firebase.auth(); // sign up const promise = auth.createUserWithEmailAndPassword(email, pass); promise .catch(e => console.log(e.message)); if (auth.currentUser != null) { auth.currentUser.updateProfile({ displayName: signup_fullname, userCategory: student__, matric: signup_matric, department: signup_dept, level: signup_level, religion: signup_religion }).then(function () { console.log("update successful"); window.readystatemode = true; }, function (error) { console.log("update failed"); }); } }); firebase.auth().onAuthStateChanged(firebaseUser => { if (firebaseUser && window.readystatemode) { console.log(firebaseUser); btnLogout.classList.remove('hide'); window.location('./dashboard.html'); } else { console.log("not logged in"); btnLogout.classList.add('hide'); } }); })(); 
+5
source share
8 answers

I had a similar problem with registering a device using Firebase, but I could log in to the browser. To solve the problem, I used the following commands:

- plug cordova remove cordova-plugin-whitelist -

- cordova plugin adds cordova-plugin-whitelist -

+3
source

Although this answer does not apply to the actual code above, I suspect that many people have a Google bug:

"Network error (such as timeout, connection abort, or unreachable host).

Perhaps your form is actually in the form element in HTML. A small mistake, but it can have huge urges. If you follow this guide: " https://www.youtube.com/watch?v=-OKrloDzGpU ", make sure your form does not have a <form></form> . This will result in this error!

+25
source

I also had a problem. The way I decided was to add the domain where the firebase application is located on the firebase console.

+3
source

In my case, the problem is resolved if you are trying to connect to the Internet.

+3
source

The solution for me was trying in Firefox. I don’t know why, but I also got an error in Chrome. You must try this. Best wishes.

+2
source

If you use Cordova (I'm not sure if you exist or not, but some answers imply that you can be), including cordova-plugin-network-information fixed this problem for me. I confirmed that "navigator.onLine" was sometimes "false" and I believe that Firebase thinks there was a problem. As soon as I added a plugin information project to the project, the problem disappeared. I did not deeply understand why, but I suspect that this plugin has a better wrapper around the navigator, which can give better Firebase information. I confirmed that this problem returned after removing the plugin, but reapplying the fix is ​​fixed. I will update this if I dig deeper. Hope this helps.

+2
source

Here is what solved the problem for me (this is for a mobile application). I could not use the tag in my html. I changed this to a div, as suggested in earlier answers. I also needed to close the keyboard. I use ionic and I need to install an ionic native keyboard. Right in front of my login function, I added this.keyboard.close() , and it worked. If you are not using ionic, you can try the cordova plugin or something similar. Hope this helps.

0
source

I solved this by disabling my ad unit, which in my case was Ghostery. It seems like it's pretty aggressive.

0
source

All Articles